tires Posted April 2, 2015 Share Posted April 2, 2015 Hello! I wonder if i can use some kind of placeholder for page-fields in a textarea (in this case with ckeditor)? The plan is, to put some text/code in a textfield that looks like this: <div> <p> The headline of the parent page is: <?php echo $pages->get("/somepage/")->theheadline; ?> The headline of this page is: <?php echo $page->theheadline; ?> </p> </div> Is there a way to do so? Or a do i have to install a additional module? Many thanks and best regards Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted April 2, 2015 Share Posted April 2, 2015 I think Hanna Code module is what solves your need. But in the example you provided you should rather adit the template file for the page and put there something like this. I think you should start with some basic tutorial and you'll figure out everything pretty soon. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 2, 2015 Share Posted April 2, 2015 I'm not fully understand what you want to do with your pagefield. But I do think a simple str_replace can do alot what you want. <?php $placeholders = array(); // loop through your page field, and create an array with your replacements. foreach ($page->multipages as $p) { // create dynamic keys => values, where the key is the url of a page $placeholders['{' . $p->url . '}'] = $p->theheadline; } // Here {/somepage/} will be replaced with the theheadline of the /somepages/ page $body = 'Vestibulum id ligula {/somepage/} porta felis euismod semper. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Vestibulum id ligula porta felis euismod semper.'; echo str_replace(array_keys($placeholders), $placeholders, $body); 1 Link to comment Share on other sites More sharing options...
tires Posted April 2, 2015 Author Share Posted April 2, 2015 Yes! Hanna is exactly what i am looking for! The str_replace is also pretty cool! I think the default templating way don't work in this special case. Because i have a pretty long text that comes from a textarea an i want to add words in there. For example: everytime the word "ball" is mentioned i want to have a placeholder befor this word that adds the headline ("red" or "blue" or "yellow") field. So on the page the word is displayed as "red ball". Thank you!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now