neophron Posted September 22, 2018 Posted September 22, 2018 Hi, this is the website structure: root -gardens -garden01 -garden02 -garden03 -garden04 -etc -contact -stuff On the gardens site I'm looping part of the fields from the child pages (garden01, garden02 etc). Some of the pages shall be linked from »gardens«, some not. I wanted to offer the editor a simple way to activate the link with one or to clicks. What I tried, was a way via hanna code. I created a hanna code with this code: <a href="<?=$garden->url;?>">read more...</a> I pasted this hannacode in a textfield (with hannacode formatter). This textfield is inside the foreach loop in the template from gardens. But the system gives me an error. I was thinking with a checkbox field and hannacode, but with no success. Do you guys have some experience with that?
bernhard Posted September 22, 2018 Posted September 22, 2018 Just place a checkbox field (eg "showlink") on the garden template (child) and in your gardens template (parent) you list your pages: // current $page is "gardens" echo "<ul>"; foreach($page->children() as $child) { $link = $child->title; if($child->showlink) $link = "<a href='{$child->url}'>$link</a>"; echo "<li>$link</li>"; } echo "</ul>";
neophron Posted September 22, 2018 Author Posted September 22, 2018 Thanks for your suggestion. I placed a checkbox in the child template (not file) and pasted your code in the parent template. Then I checked the link in backend The thing is, that this code must be inside a foreach loop. The main loop starts with this: <? foreach($page->children() as $garten):?> After pasting your code, the front-end shows all subpages as a ul and this doesn't make sense. I need only the link to the source (child) page. Usually I would paste this code for showing all links to the subpage: <a href="<?=$garten->url;?>">Weiterlesen...</a>
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