Jump to content

Recommended Posts

Posted

I have an area of content 'Upcoming Events' which has title, text, image etc.. I want to be able to make visible on a page and then sometimes remove it.

At the moment I can unpublish an 'Upcoming Events' page and that content is removed from the page where I display it, but i still have a bunch of empty HTML tags left over.

What is the best way to have an area of content turn 'off' without leaving any trace?

Posted

Depends on how you code that part. :)

So I'd guess (without seeing your code) you have some echos in there that isn't conditional.

Posted

Soma is right, it all comes down to how you code it and where you put your conditionals. Feel free to post your code here and we can have better context to make suggestions.

Posted

You could setup a checkbox field called "hidden" and only show it if it's unchecked.

<?php
$items = $pages->get("/page/")->find("hidden=0");
echo "<div><p>content</p></div>";
Posted

Hi Soma, Ryan and Marty,

So i have a page using a template named 'upcoming-exhibitions' which contains all the content.

I want to display some of that content on it's parent page (exhibitions) where i want to be able to turn on and off… so to speak.

So on my exhibitions page I currently have this:

<?php
$item = $pages->get("template=upcoming-exhibitions");
echo "<h2>{$item->title}</h2>";
echo "<img src='{$item->exhibition_image->size(100,100)->url}' alt='$item->description'/>";
echo "<p>{$item->exhibition_summary}</p>";
?>
Posted

put a checkbox on the main page template (it's more efficient since you don't even have to call the other page)

and do this:

<?php
if($page->checkbox){
$item = $pages->get("template=upcoming-exhibitions");
echo "<h2>{$item->title}</h2>";
echo "<img src='{$item->exhibition_image->size(100,100)->url}' alt='$item->description'/>";
echo "<p>{$item->exhibition_summary}</p>";
}
?>

Or, if you still prefer to have the checkbox on the exhibitions page:

<?php
$item = $pages->get("template=upcoming-exhibitions");
if($item->checkbox){
echo "<h2>{$item->title}</h2>";
echo "<img src='{$item->exhibition_image->size(100,100)->url}' alt='$item->description'/>";
echo "<p>{$item->exhibition_summary}</p>";
}
?>
  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...