Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Page Title from DataObject


Go to End


3 Posts   1762 Views

Avatar
potion_maker

Community Member, 36 Posts

10 December 2009 at 9:58am

I'd like to add information to my Page Title from a couple of dataObject fields. Basically I have two fields FirstName and LastName. I can retrieve the info and display it on the page fine but I am having trouble telling the Page's Title to add the new information. Any suggestions would be helpful. Thanks in advance

Avatar
Willr

Forum Moderator, 5523 Posts

10 December 2009 at 11:50am

So how are you displaying the dataobject on the page and how are you displaying the title on the page?. Might be easier if for the <title> tags you don't use the built in $MetaTags function instead do something like..

<head>
..
$MetaTags(false) 
<title>$Title - <% if DataObject %>$Field<% end_if %></title>
</head>

Avatar
potion_maker

Community Member, 36 Posts

10 December 2009 at 1:40pm

Edited: 12/12/2009 6:35am

The DataObject is loaded in new page that extends Page (i.e. MyPage.php [MyPage extends Page] ). So in MyPage.ss I can do <% if DisplayPerson %>$FirstName $LastName<% end_if %>

If however I call the same thing from Page.ss I get nothing. Do I need do something like <% if MyPage.DisplayPerson %>$FirstName $LastName<% end_if %>

SOLVED by <% if_MyFunction %><% control_MyFunction %>$FirstName $LastName<% end_control %><% end_if %>