332 Posts
Kenneth
8 years ago
25
Topic

Hi,

I'm trying to get article title as value for a field. Not succeeding. 

I've tried with SD live field without luck. I've tried with 42 field, without understanding what to do with it (I added code to get the title, and I did, but I cant find out how I can use that further...no storage? No field in output?)

If there was a way I could use live value in the select dynamic field, I could get the article title by using ID as live value.. but I cant find any post about using another field/live value with the select dynamic field.

Get a VIP membership
233 Posts
pepperstreet
8 years ago
0
Level 1

Hello Kenneth, 
would you mind to give some details, please...

Which title and in which context? What is the purpose and goal?

8 years ago
0
Level 1

Hi Kenneth,

don't really understand what is your need.

Can you explain a little more your context (which view, content type, searh type, ....) ?


Best regards.

Lionel

332 Posts
Kenneth
8 years ago
2
Level 1

Oh, sorry.

I have created an app to get feedback on content. So I load this content type (site form) with seblod form module in a ordinary template position.

I this feedback app I have created a field where I get the url to the page where the feedback is submitted which is working great, but I also want the page title. I can get the page title with php/joomla api, but not in to a field as a value to be stored with the form. :(

332 Posts
Kenneth
8 years ago
0
Level 2

The goal is to place "page titel" as a live value in the field, so that when it is saved it saves the page title.

233 Posts
pepperstreet
8 years ago
0
Level 2

As far as you can access and get the current pagetitle, you should be able to store it with the Code Pack product:

http://www.seblod.com/products/1854

See respective tutorial as attachment.

332 Posts
Kenneth
8 years ago
2
Level 1

Thanks for the tips. I've tried this now, without getting the result I want. 

I've tried:

$pagetitle= JFactory::getDocument();
$pagetitle->getTitle();
$fields['art_title']->value = $pagetitle;

$config['storages']['#__content']['title']=$pagetitle;

Also, this code dosn't generate anything to work from:

var_dump($config);die();)

All code is entered when using the field at BeforeStore, Free.. The alias is blank, so it's not getting anything.

332 Posts
Kenneth
8 years ago
0
Level 2

No wonder it's blank; if I var_dump $pagetitle it dosn't have the title anywhere. (Only global site title)

When the form submits, it loads a new page - and this is the page the code is executed on - so the title of the page where the form is submitted is gone.

I'm trying to play with beforerender as well, trying to store the current page title in a $variable and to pick it up on beforestore.. not having any luck doing so..

233 Posts
pepperstreet
8 years ago
0
Level 2

Getting the page title looks strange, IMHO. Please try:

$doc = JFactory::getDocument(); 
$page_title = $doc->getTitle();

BTW, are we talking about the same title? ;) There is often a confusion about titles, there is ArticleTitle, PageTitle, PageHeader. The PageTitle should be displayed in your browser's window bar... 

If it is really "blank", it might be a template/framework override issue. Or you might have set some parameters in your MenuItem...

332 Posts
Kenneth
8 years ago
14
Level 1

Thank you again, pepperstreet.

I've tried the code you pasted as well with the same result. 

That might be smart.. :) It's in fact the article title I'm looking to capture.

233 Posts
pepperstreet
8 years ago
13
Level 2

Have mercy, I am a designer! ;) 

1.) So, my guess is that it is a special case because you want to access the information from a module. I believe you have to create an article object first, before your form module can get the current article info... This should be possible by the Object, or even a DB query (SD Databaser, SQL Pack). But why creating extra queries, if the information is already loaded somewhere ;) 

You mentioned you already got the URL?! You might also get the current article ID from it. Wasn't there a free Seblod product to get values from URL? Maybe checking the article context is not crucial in your case, but good practice anyway... I ommited it in the following example:

$input = JFactory::getApplication()->input;
$id = $input->getInt('id');  //get the article ID
$article = JTable::getInstance('content');
$article->load($id);
$article_title = $article->get('title');  // get the article title

2.) Another option could be to use SD Live CCK Field: 

http://www.seblod.com/products/2311

Not 100% sure, but if it is placed in your form module, it seems to get the field data from the current full viewed article... (please read the description, because it mentions list/search modules only. Maybe forms is not the best context to use it anyway!?) 

 

332 Posts
Kenneth
8 years ago
12
Level 3

Ah, I appreciate you trying to help! No worries. ;)

Yes, I can get the article ID but I do not know what to do with it to get the article title. :) So I'm lost. :P

I used the SD Live CCK field as well, but did not manage to get any values at all with it. Probably because what you wrote, not to use it in forms. :)

8 years ago
11
Level 4

Hi kenneth,

and thank pepperstreet for your contribution, your two solutions are good.

After that, the title must be stored with the feedback form. 

I would do like that :

  • add a hidden field "Feedback Parent Title" in the feedback form with the storage "standard | article | parent_title"
  • write the code given by pepperstreet to get the title in a field beforerender
  • In the field beforerender, add the code below:
$fields['feedback_parent_title']->value = $article_title;<br>


Best regards.

Lionel

332 Posts
Kenneth
8 years ago
0
Level 5

Thanks. I will give this a go.

233 Posts
pepperstreet
8 years ago
0
Level 5

Hello Lionel, one related question to accessing data from a "parent" article. Is there a difference with the product "SEBLOD Form & List Pack" ? I mean, is it easier to get values from the parent list/Item ? 

11 Posts
cerise
8 years ago
8
Level 5

Hi Lionel,

I’m facing the same issue. I need to pre-fill dynamically the form field «article title » of my comment module with the article title of the main article. Then after saving the form, the comment will have the same article title as the main article. Only the title alias will be different.

I’ve followed your instruction concerning copying pepperstree’s code in a beforerende’s field + add your code at the end (with the code pack plugin).

$input = JFactory::getApplication()->input; 
$id = $input->getInt('id');  //get the article ID 
$article = JTable::getInstance('content');
$article->load($id);
$article_title = $article->get('title');  // get the article title
$fields['feedback_parent_title']->value = $article_title;

I’ve created a hidden field as you advised but unfortunately I have no result.

Is there something I'm missing or have misconfigured ?

Could you explain more in detail how to achieve this.

Regards

595 Posts
Octopoos - Mehdi
8 years ago
7
Level 6

Hi cerise,

Thank you for your post.

We can propose you an easier solution with a new plugin in the market.

In your contact form :

  • click on button "2" to select option "SQL query" as a live feature for the "Article Title" field and the option "Datetime" as a live feature for the "Article Alias" field
  • click on a link "configure" on the live value column of the "Article Title" field
  • add the following code in the appeared light box
SELECT c.title FROM #__content AS c WHERE c.id = $uri->get('id') AND c.state = 1

Regards,
Mehdi

11 Posts
cerise
8 years ago
2
Level 7

Thanks for your answer.

Are you talking about the SQL Pack (3 plug-ins)

Regards, Cerise

595 Posts
Octopoos - Mehdi
8 years ago
1
Level 8

Yes, you are right.

Regards,
Mehdi

11 Posts
cerise
8 years ago
0
Level 9

Thanks so much Medhi, its exacltly what I needed.

Regards, 

Cerise

123 Posts
EclipseMedia
8 years ago
3
Level 7

I can't find Datetime for Article Alias. I need that because the article created is being named the same as the main content type causing alias conflicts. Where do I finf datetime. or can I use MYSQL and run a query to load the Date and Time?

332 Posts
Kenneth
8 years ago
2
Level 8

Hi

You need this. 

http://www.seblod.com/store/extensions/2191

123 Posts
EclipseMedia
8 years ago
1
Level 9

Thank you Kenneth. Works perfect now :)

332 Posts
Kenneth
8 years ago
0
Level 10

Perfect! :)

8 years ago
0
Level 1

Hi,

To debug and see what your objects contain I invite you to use J!Dump http://extensions.joomla.org/extension/j-dump

Thanks

332 Posts
Kenneth
8 years ago
0
Level 1

Thanks. I use var_dump and print_r in the custom template on $cck at least. Will I see more with the plugin you mention? 

And, if not within $cck - Any ideas what I should start with? :)

Get a Book for SEBLOD