1

I have a custom CMS here entitled phpVMS, and I want to exclude a piece of code, a banner for a single page. phpVMS is steered using templates, for instance, the main template that codes the general layout for all pages is entitled layout.tpl. So, like I said, this displays whatever is in the template, on all of the pages. I have however created a special control panel, and therefore require to exclude the banner, because it slightly destroys the theme of it. Is there any PHP code that excludes a piece of code on a single site? I need to remove a single div...

<div id="slideshow"></div>

...on a single page.

Basically, I could create a new template but this is a very long winded and unefficient way within this CMS, and the final result isn't that great - because I can't reinclude the mainbox div which is the box defining the content on the centre white bit of the theme - it's already in the layout.tpl.

I hope you can somehow help me, hope I've included enough information there.

Thanks.

1
  • not an answer per se, but does adding the js (assuming you are using jquery) $("#slideshow").hide() ; fix the issue while you are looking for a perm. solution? Commented Mar 19, 2012 at 18:08

4 Answers 4

2

If you use a variable to determine you don't want to include the div, you could do this:

<?php if ($include) { ?>
    <div id="slideshow"></div>
<?php } ?>

OR

<?php
    if (!$include)
        echo "<!--";
?>
<div id="slideshow"></div>
<?php 
    if (!$include)
        echo "-->";
?>

EDIT: Obviously, there is no good reason to use the second method. The second method will only comment out the HTML so it will still show up in the source.

Sign up to request clarification or add additional context in comments.

1 Comment

The template layout.tpl defines all of the pages content, where div slideshow is now. I've added the above code to profile_main.tpl at the top of it, and it doesn't work. I guess you've mentioned a variable, how would I make one? Sorry, still learning PHP...
1

I don't think you can do what you're asking in PHP, but you might be able to do this on the client-side, by either hiding the div (CSS display:none) or by removing it with JavaScript. You might be able to do something like:

<?php
    include("layout.tpi");

    if (condition)
    {
        // Javascript:
        echo "<script>document.getElementById('slideshow').style.display = 'none';</script>";

        // OR jQuery:
        echo "<script>$('#slideshow').hide();</script>";
    }
?>

1 Comment

Thanks, that worked without the include, as the template is already included :)
0

I'm not sure if this is what you are looking for, but seems simple

<?
$template = true;
if($template) {
?>
<div id="slideshow"></div>
<?
}
?>

Comments

0

On the template, you could have some code that reads:

if($_SERVER['PHP_SELF'] == /*control panel file*/) {
     //exclude
}else{
     //include
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.