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.

Archive /

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

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

Fixed : Customising content


Go to End


4 Posts   1461 Views

Avatar
Laax

Community Member, 14 Posts

17 September 2008 at 7:01pm

Edited: 24/09/2008 3:55am

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,

Avatar
Fuzz10

Community Member, 791 Posts

17 September 2008 at 7:42pm

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 ?

Avatar
Hamish

Community Member, 712 Posts

18 September 2008 at 9:55pm

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

Avatar
Laax

Community Member, 14 Posts

24 September 2008 at 3:55am

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.