Page 1 of 1
Replacing part of content before render
Posted: Wed Jun 08, 2011 8:54 am
by Fatin
Hi,
I add content page in Administration Panel of CMS MS. In this content I have few images. Before displaying it on page I want to replace each "img src" string with 'img class="example_class" src'. I was looking for a part of code which is responsible for displaying content on page, but after a few hours I didn't find it....
Re: Replacing part of content before render
Posted: Wed Jun 08, 2011 9:03 am
by uniqu3
Do you mean the content that is entered in TinyMCe and called with {content} in template?
In TinyMCE you can add a class to image, when adding it in content.
So in the image popup of TinyMCE there is tab appearance, where you can select a class available from your stylesheet.
Else is it's all images inside {content} tag you could use smarty replace like {content|replace:'<img':'<img class="example_class"'}
Else you should be more specific, what content and what images

Re: Replacing part of content before render
Posted: Wed Jun 08, 2011 9:45 am
by Fatin
Thank you for your reply

I know that I can add class to img in TinyMCE, my client also knows it, but sometimes he didn't remember

So I think that the best issue will be adding class name to img before displaying it using php. So I can't find place in source where is it getting from database before render...
Re: Replacing part of content before render
Posted: Tue Jun 14, 2011 8:10 am
by nervino
If you want to style each image in content or in a part of it (and if I understood correctly what you need), why don't use stylesheet's rules?
For example, if you have a content area in a div with id="mydiv" you can make a stylesheet rule: #mydiv img {whatever..}.