The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 
Author Message
PostPosted: Wed Apr 11, 2007 2:57 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Jun 26, 2006 6:21 pm
Posts: 27
Hi,

I had posted it in the wrong section before.

I would like to findout from a template/frontend which page is being displayed.
It could be the menu item id or the page title.

Any pointers on how to accomplish this are very welcome, like the related API to use.

-rsd

_________________
http://www.dias.com.br


Top
 Profile  
 
PostPosted: Wed Apr 11, 2007 12:48 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 963
Location: Washington, DC / NoVA
If you want the current menu item number, you can find it stored in $Itemid. For the current page title, try calling $mainframe->getPageTitle().

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
 Profile  
 
PostPosted: Wed Apr 11, 2007 1:36 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Jun 26, 2006 6:21 pm
Posts: 27
Great!!
Exactly what I needed.

Thank you

_________________
http://www.dias.com.br


Top
 Profile  
 
PostPosted: Thu Apr 12, 2007 1:06 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Jun 26, 2006 6:21 pm
Posts: 27
jlleblanc wrote:
If you want the current menu item number, you can find it stored in $Itemid. For the current page title, try calling $mainframe->getPageTitle().


Interesting that $Itemid solves my problem, getPageTitle returns the html page title (which I think is determined by the component), and not the menu "Page Title" option which is different.

Tried to inspect includes/joomla.php, but couldnt find a method to get the "Page Title" from the menu option.  Any lights on this.

Thanks.

_________________
http://www.dias.com.br


Top
 Profile  
 
PostPosted: Thu Apr 12, 2007 6:50 pm 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso
Offline

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4778
Location: Toronto, Canada
global $database;

$menu =& new mosMenu( $database );
$menu->load( $itemId );
echo $menu->name;

Ian


Top
 Profile  
 
PostPosted: Fri Apr 13, 2007 1:57 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Jun 26, 2006 6:21 pm
Posts: 27
Great!! That solved it.

Thanks

-rsd

_________________
http://www.dias.com.br


Top
 Profile  
 
PostPosted: Tue May 15, 2007 2:35 pm 
User avatar
Joomla! Explorer
Joomla! Explorer
Offline

Joined: Thu Nov 10, 2005 8:05 am
Posts: 297
Location: Western Australia
Hi guys, directed to your post, trying to work out how I can get the title of the page to show up in text, i.e. if I have a content item with a title called sometitle, I want to place that text (sometitle) in the content (using mossnippet to help me do that).  so by adding 'whatever' code will show me the title of the page.  I'm using it to append other text that is used in linking like content by way of using the simply links component

I've tried various ways based on your code above but my poor php skills are showing :(

Any chance you can advise what the correct php code is for me to pull up the content title for the specific content item being viewed?

_________________
If you don't ask....
Help yourself, use Firebug with Firefox
Server Info: Joomla!: 1.5.23 and 1.7.3 | PHP: 5.2.17 | MySQL: 5.0.92 | Perl: 5.8.8 | Live server: Apache 2.2.17 / Dev Server XAMMP | Template: Custom


Top
 Profile  
 
PostPosted: Wed May 16, 2007 12:15 am 
User avatar
Joomla! Explorer
Joomla! Explorer
Offline

Joined: Thu Nov 10, 2005 8:05 am
Posts: 297
Location: Western Australia
Found it :)

Code:
<?php
global $mainframe;
$fulltitle = $mainframe->_head['title'];
$sitename = $GLOBALS['mosConfig_sitename'] . ' - ';
$pagetitle = str_replace($sitename, '', $fulltitle);
echo $pagetitle;
?>


Yipee :)

_________________
If you don't ask....
Help yourself, use Firebug with Firefox
Server Info: Joomla!: 1.5.23 and 1.7.3 | PHP: 5.2.17 | MySQL: 5.0.92 | Perl: 5.8.8 | Live server: Apache 2.2.17 / Dev Server XAMMP | Template: Custom


Top
 Profile  
 
PostPosted: Thu May 17, 2007 4:45 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Sun Sep 25, 2005 3:57 pm
Posts: 96
Location: Atlanta, GA
This thread has been very helpful.  What variable would I call if I wanted to print the "title alias" from a static content page?

Thanks again for the help!

_________________
http://www.intownwebdesign.com


Top
 Profile  
 
PostPosted: Thu May 17, 2007 4:57 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 963
Location: Washington, DC / NoVA
You would need to load the content item from the database to get that information. This code should do it:

Code:
global $database;

$id = mosGetParam($_REQUEST, 'id', 0);

$row = new mosContent($database);
$row->load($id);

echo $row->title_alias;

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
 Profile  
 
PostPosted: Thu May 17, 2007 5:15 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Sun Sep 25, 2005 3:57 pm
Posts: 96
Location: Atlanta, GA
Worked like a charm!  Thanks

My next step is to select the background image based upon the value that is entered into the title alias.

I am new to php so I have some more research to.  Any tips on how to do this? 

I have started a thread in the Template and CSS forum:
http://forum.joomla.org/index.php/topic ... html&nbsp;

I am excited to be making some progress!

Thanks Again

_________________
http://www.intownwebdesign.com


Top
 Profile  
 
PostPosted: Thu May 17, 2007 9:54 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Sun Sep 25, 2005 3:57 pm
Posts: 96
Location: Atlanta, GA
Hi jlleblanc,

Thank you very much for your help.  Like I said my php and joomla dev skills are not the strongest right now.  Where could I go to start to learn more about the variables and what the code that you provided me is doing line by line?  I have put a write up of what i have done:  http://www.drretarded.com/websites/joom ... html&nbsp; I would love to be able to provide further explanation for myself and others.

Any input you have is greatly appreciated!

_________________
http://www.intownwebdesign.com


Top
 Profile  
 
PostPosted: Thu May 17, 2007 11:39 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 963
Location: Washington, DC / NoVA
Here's a set of tutorials you can reference: http://forum.joomla.org/index.php/topic,63383.0.html

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
 Profile  
 
PostPosted: Fri May 18, 2007 12:53 am 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Fri May 12, 2006 2:16 am
Posts: 51
Location: China
thanks

_________________
My blog http://yustar.joomlar.cn


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 



Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group