Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Fixed : Customising content

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1135 Views
  • Laax
    Avatar
    Community Member
    14 Posts

    Fixed : Customising content Link to this post

    Hi,
    I have a little problem with the recipe "customising-content-in-your-templates" .

    I need to put an image inline with the content at the end of the paragraph like a punctuation mark. So i tried the recipe and though it seems so simple it doesn't show anything on the published site. Flushed the page many times but no way.

    I put this code into my PageType_Controller

    function Content() {
    return $this->Content.'<a class="info_btn" href="$Link"><img src="$ThemeDir/images/info_btn.png"/></a>';
    }

    even if I test with something like : return str_replace('have ','TEST',$this->Content) ;
    i doesn't work.

    Can someone help me on this?
    Thx,

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Fixed : Customising content Link to this post

    I don't see why this isn't working...

    I'm doing the exact same thing in multiple sites....

    Are you sure you are putting your content in the default "content" field ?

    Is very other page in your site extending Page_Controller ?

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Fixed : Customising content Link to this post

    Why is it in the controller? Try it in the PageType class.

  • Laax
    Avatar
    Community Member
    14 Posts

    Re: Fixed : Customising content Link to this post

    Thx guys,
    Finally the code's working fine and the bug was from another part of the code.

    But the code didn't help me to do what i wanted to do : adding a punctuation mark at the of the text. $this->Content is wrapped into a <p> tag and the mark happened after the </p> ending.

    I managed to get the Dataobject and handle string with php methods to add my mark before the </p>

    @Hamish : it seems that it doesn't matter whether the function is in PageType class or the controller one.

    1135 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.