|
|
#1 |
|
Junior Member
Join Date: Oct 2006
Posts: 24
Rep Power: 11 ![]() |
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:
|
|
|
|
|
|
#2 |
|
Moderator
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100 ![]() ![]() |
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 |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2006
Posts: 24
Rep Power: 11 ![]() |
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. |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100 ![]() ![]() |
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 |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Oct 2006
Posts: 24
Rep Power: 11 ![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Moderator
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100 ![]() ![]() |
Quote:
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 |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |