Click to See Complete Forum and Search --> : Using PHP can I ignore certain areas of code on some pages.
pauladkins1974
10-24-2006, 05:53 AM
Hello All
I use Joomla CMS which is great but doesn't allow me to do what I need.
Basically I need to ignore certain parts of my template code on very specific pages.
Joomla (PHP based CMS) has some functionality in this area but I want to fine tune this.
Does anyone know how to ignore areas of code for certain URLs using PHP?
I may also want to ignore certain URL patterns using wild cards as the CMS generate so complex URL's.
Thanks in advance.
Cheers
Paul
pauladkins1974
10-24-2006, 03:16 PM
Anyone?
Just to summerize - I use a PHP based CMS and need to find a way to stop some code appearing on certian pages/URLs.
Any help is most appreciated.
Cheers
Paul
carlh
10-24-2006, 03:26 PM
can you give an example of your code? Is CMS just short for a content management system or is there a particular software out there called CMS? just a general way is if you're basing it off of a condition you can use an if statement in php
<?
if(condition==true){
//whatever you want it to do
}
?>
pauladkins1974
10-25-2006, 04:44 AM
Hello Carlh
Thanks for your reply.
I'm using Joomla (an open source content management system) and I want certain pages to not show a specific module.
The pages that I don't want the code in are individual pages within a component, Joomla can't offer this level of control.
My code isn't very revealing I'm afraid as all the PHP controlling the appearance of this module is handled by the CMS.
But this is the area of code I'm working with, any idea how I would stop the PHP within the bannerbox div from rendering on specific pages/page ranges using PHP.
Note: For my purposes using CSS display: none; won't achieve what I need
<div id="banner">
<?php mosLoadModules ( 'user1', -2); ?>
<div id="bannerbox">
<?php mosLoadModules ( 'user2', -2); ?>
</div>
</div>
Hope you can help.
Cheers
Paul
pauladkins1974
10-25-2006, 02:53 PM
Hello All
I think I've made some headway - can anyone fill in the blanks (blanks = ???????????????).
Just to warn you there may be other errors too.
Just to let people know I want to detect the URL in the address bar of the browser and when it contains a url specified by the $nodisplay variable the mosLoadModules ( 'header', -2); code will not run. Basically I don't know how to reference the URL.
I use Joomla CMS by the way.
<html>
<head>
<?php
$url = ?????????????????;
$nodisplay = "index.php?option=com_frontpage&Itemid=1";
?>
</head>
<body>
<div id="header">
<?php
if ($nodisplay == $url)
{
return;
}
else
{
mosLoadModules ( 'header', -2);
}
?>
</div>
</body>
</html>
Hope someoine can help
Cheers
Paul
carlh
10-30-2006, 05:40 PM
if you're trying to change the header i think it's got to be at the very top of the page, so you're trying to make it so if a variable the url= "index.php?option=com_frontpage&Itemid=1" they will get redirected? You'll have to use $_SERVER variables to get the url, or if you're just checking Itemid it'd probably be easier just to get that 1 variable
<?php
$nodisplay = $_GET['Itemid'];
if($nodisplay == 1) {
header("location: page_without_everything.php");
} else {
header("location: page_with_everything.php");
}
?>