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.

Archive

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

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

Fixed : Customising content


Reply

4 Posts   1141 Views

Avatar
Laax

17 September 2008 at 7:01pm (Last edited: 24 September 2008 3:55am), Community Member, 14 Posts

Hi,
I have a little problem with the recipe [url=http://doc.silverstripe.com/doku.php?id=recipes:customising-content-in-your-templates] "customising-content-in-your-templates" [/url].

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

17 September 2008 at 7:42pm Community Member, 787 Posts

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

18 September 2008 at 9:55pm Community Member, 712 Posts

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

Avatar
Laax

24 September 2008 at 3:55am Community Member, 14 Posts

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.