Support Forums

Old 10-19-2006, 11:57 AM   #1
Junior Member
 
Join Date: Oct 2006
Posts: 24
Rep Power: 11
flyingpylon is on a distinguished road
Default Problem getting page title

I'm trying to extract the title of a static page for use in a template and I'm having some difficulty.

Unfortunately, the default $title variable assigned when a static page is loaded prepends the site name to the title (My Site Name - Page Title). Also, it appears that when the page is loaded, an array of all the page IDs and page titles is assigned, but I can't figure out how to get the title of just the page I want.

I have tried looping through the $templatepages array and doing a comparison with the requested page ID to get the appropriate title, but for some reason I keep getting the first title in the array, not the one I wanted.

I have tried many different possibilities, but here is my current code:

PHP Code:
{if $SCRIPT_NAME == "/classifieds/pages.php"}
    {foreach 
from=$templatepages item="entry"}
        {if 
$entry.pageID == $smarty.get.page}
            {
assign var=pagetitle value=$entry.pPageTitle}
        {/if}
    {/foreach}
{/if} 
I'm still pretty new to Smarty, so maybe I'm making a simple mistake?
flyingpylon is offline   Reply With Quote
Old 10-19-2006, 12:05 PM   #2
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100
Lhotch is just really niceLhotch is just really nice
Default

How about....

{$title|replace:'your site title here':''}

the above would replace "your site title here" with nothing thereby eliminating your sitename from the $title variable.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 10-19-2006, 12:18 PM   #3
Junior Member
 
Join Date: Oct 2006
Posts: 24
Rep Power: 11
flyingpylon is on a distinguished road
Default

DOH!! I figured this out on my own.

If the page is marked to NOT be displayed in the navigation, then its corresponding data will not be included in the $templatepages array.

Actually, I think this is an odd feature. Why should a page have to be displayed in the navigation automatically in order to be able to get its title? Now I will need to remove the automatic display of pages from my template and enter the ones I need manually. Not a big deal, but it seems odd to have to do that.

Larry- good idea about the replace, but in my opinion the page title should be present in its own, easy to get variable. If for some reason the site name changed even slightly the code would need to be updated. Though I assume I could also just use the constant for the site name instead of hard-coding it.
flyingpylon is offline   Reply With Quote
Old 10-19-2006, 12:25 PM   #4
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100
Lhotch is just really niceLhotch is just really nice
Default

I assume the site title and page title are concatonated at the script level to keep things simple. I guess it could have just eas easily be done at the template level but it would mean adding an additional smarty variable assignment at the script level and then displaying both variables in the template. 6 of one half dozen of the other I guess.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 10-19-2006, 12:42 PM   #5
Junior Member
 
Join Date: Oct 2006
Posts: 24
Rep Power: 11
flyingpylon is on a distinguished road
Default

Quote:
Originally Posted by Lhotch View Post
I assume the site title and page title are concatonated at the script level to keep things simple. I guess it could have just eas easily be done at the template level but it would mean adding an additional smarty variable assignment at the script level and then displaying both variables in the template. 6 of one half dozen of the other I guess.
No, not really. If you have the Designer version it makes things much more difficult. I will be making some feature suggestions when I have more time, but in short I'm finding many places where presentation is being mixed in with coding logic and I was originally under the impression that by utilizing a template engine like Smarty that would not be the case. So far the problems have not been insurmountable, but they've made customization take longer than it really needs to.
flyingpylon is offline   Reply With Quote
Old 10-19-2006, 01:15 PM   #6
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100
Lhotch is just really niceLhotch is just really nice
Default

Quote:
Originally Posted by flyingpylon View Post
No, not really. If you have the Designer version it makes things much more difficult. I will be making some feature suggestions when I have more time, but in short I'm finding many places where presentation is being mixed in with coding logic and I was originally under the impression that by utilizing a template engine like Smarty that would not be the case. So far the problems have not been insurmountable, but they've made customization take longer than it really needs to.

In a perfect world logic would be seperate from presentation but if you look at every template engine out there, they all offer people the ability to use logic via the template engine which is against the very reason for their existance. From a purist point of view its an oxymoron at best. Template engines dont eliminate logic from presentation but they can significantly reduce it and where it does exist it can be greatly simplified.

One thing I have learned during my time here, for every item one person wants to function a certain way, there is usually someone who wants it to function a different way.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I run scripts in an content page? dawyatt v3.1 Questions & Support 11 06-22-2007 02:50 PM
Title question Fedeo v3.0 Questions & Support 9 01-25-2007 01:38 PM
Modify Page Titles For Individual Ads bgordon v3.1 Modules & Modifications 5 11-24-2006 03:37 PM
Adding a (sub)category picture and title jamesbond v3.1 Questions & Support 4 08-11-2006 07:45 AM
Alter cats page build v3.0 Questions & Support 9 04-10-2006 06:58 PM


All times are GMT -4. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0