Jump to:

23369 Posts in 18155 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Page Title from DataObject

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

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

Page: 1
Go to End
Author Topic: 1056 Views
  • potion_maker
    Avatar
    Community Member
    36 Posts

    Page Title from DataObject Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Page Title from DataObject Link to this post

    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>

  • potion_maker
    Avatar
    Community Member
    36 Posts

    Re: Page Title from DataObject Link to this post

    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 %>

    1056 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.