Need some ideas on pages and posts (nee WP)

doobs
Ssr. Bludit
Posts: 17
Joined: Fri Dec 06, 2024 1:07 am
Has thanked: 1 time

So,

After quite a bit of to-ing and fro-ing, the foreach statement looks like:

Code: Select all

	
<?php foreach ($staticContent as $staticPage): ?>
	<?php if (!$staticPage->isChild() && $staticPage->template() !== "hidden"): ?> 
		<li class="<?php echo ($staticPage->permalink()==$page->permalink())?'active':'' ?>"><a href="<?php echo $staticPage->permalink() ?>#main"><?php echo $staticPage->title() ?></a></li>
	<?php endif; ?>	
<?php endforeach ?>
This works as desired.

Thank you!
chris
arfa
Master Bludit
Posts: 163
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 27 times

Awesome..!

Having found the official approach I am planning to use custom code as I move forward. It creates a checkbox for each page so, once it is set up, is probably easier than typing 'hidden' each time. Your second line would then read...

Code: Select all

<?php if (!$staticPage->isChild() && !$page->custom('hidden')
The choice is of course entirely yours.

Great that you have it working.
ak
Post Reply