getPageTitle();but all I get out of that is "faq" despite the fact that the "listing" title is correct in the browser title area. ??Anyway, assuming that all makes sens, thanx a ton for taking a look!"> variable from another component loaded into form - Forums

Forums

variable from another component loaded into form

marklandry 26 Mar, 2011
Hey guys,

I'm using {loadposition formname} to load a form into the output page of a Joomla component (Jreviews)
I'm trying to pass a variable from the Jreviews page into the form using the Jreviews api for page (or "listing") title. Here's the variable I'm trying to pass:

global $title;
$title = $listing['Listing']['title'];


I've declared the same thing in the form .php area but can't get it to echo in the form. I can do it the hard way and make a database dip but it would be a ton better to use the api if it's possible.

Also, I tried calling the page title using
global $mainframe;
echo $mainframe->getPageTitle();

but all I get out of that is "faq" despite the fact that the "listing" title is correct in the browser title area. ??

Anyway, assuming that all makes sens, thanx a ton for taking a look!
GreyHead 26 Mar, 2011
Hi Mark,

Can't be of much help as I don't have load position or JReviews. (Why are you using loadposition instead of the ChronoForms plug-in?)

As far as I an see the approach you are using ought to work provided that the code executed in more or less the correct order.

Bob
marklandry 27 Mar, 2011
Didn't know there was a plugin - that makes life a little easier.
Using that now but still no dice.

For some reason using the Joomla API for page title is pulling menu item names associated with JReviews as opposed to the article title ??

Anyway, thanx for taking a look!

I ended up going with this:


if (JRequest::getVar('option')=='com_content' && JRequest::getVar('view')=='article') {
    // get the article id from request
    $id = JRequest::getVar('id');
    // some pages (e.g. within a category) return  'id:alias' - need to strip this down to just id
    if ( strpos($id,':') > 0 ) {
        $id = substr($id,0,strpos($id,':'));
    }
    // get the article title from the database
    $db = JFactory::getDBO();
    $db->setQuery('SELECT title, id FROM #__content WHERE id=' . $id); // joomfish needs primary key in select
    $page_title = $db->loadResult();
}
GreyHead 27 Mar, 2011
Hi Mark,

If it's a JReviews page then presumably JReviews must be setting the document title from the menu?
This isn't technically a Joomla! article as it isn't a com_content page.

Bob
This topic is locked and no more replies can be posted.