Hi I am trying to test for arg(1) OR is_front however when I set this up neither seem to work but if I do them separately they work fine. I assume it's just my syntax but I'm honestly not sure. Any help would be great.
Here is what I have: <?php if (arg(1) != "27") || (!$is_front): ?>
I also tried this as well but to no avail. <?php if (arg(1) != "27" || arg(1) != "27"): ?>
Chris McCreery ha scritto:
Hi I am trying to test for arg(1) OR is_front however when I set this up neither seem to work but if I do them separately they work fine. I assume it's just my syntax but I'm honestly not sure. Any help would be great.
Hi, where do you check this ? $is_front is available only in page(-*).tpl.php file, while $vars['is_front'] is available in themename_preprocess_page($vars) function.
M.
Hi Michel I am testing for this in my page.tpl.php trying to display a certain <div> when arg(1) doesn't equal 27 or 39.
On Sun, Jul 11, 2010 at 8:40 PM, Michel Morelli michel@ziobuddalabs.itwrote:
Chris McCreery ha scritto:
Hi I am trying to test for arg(1) OR is_front however when I set this up neither seem to work but if I do them separately they work fine. I assume it's just my syntax but I'm honestly not sure. Any help would be great.
Hi, where do you check this ? $is_front is available only in page(-*).tpl.php file, while $vars['is_front'] is available in themename_preprocess_page($vars) function.
M.
-- Michel 'ZioBudda' Morelli michel@ziobuddalabs.it Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_buddahttp://www.ziodrupal.net MSN: michel@ziobuddalabs.it JABBER: michel@ziobuddalabs.it
-- [ Drupal support list | http://lists.drupal.org/ ]
Chris McCreery ha scritto:
Hi Michel I am testing for this in my page.tpl.php trying to display a certain <div> when arg(1) doesn't equal 27 or 39.
Ok, for test at the top of page.tpl.php file write
echo $_GET['q'];
and see which is arg(1)
M.
I get node/10 so then arg(1) would be 10 correct? If I test for just arg(1) != "10" it works but when i try to combine multiple conditions doesn't work for me. I'm definitely not a php programmer so I'm sure it's a stupid error on my part.
Thanks,
On Sun, Jul 11, 2010 at 8:51 PM, Michel Morelli michel@ziobuddalabs.itwrote:
Chris McCreery ha scritto:
Hi Michel I am testing for this in my page.tpl.php trying to display a certain <div> when arg(1) doesn't equal 27 or 39.
Ok, for test at the top of page.tpl.php file write
echo $_GET['q'];
and see which is arg(1)
M.
-- Michel 'ZioBudda' Morelli michel@ziobuddalabs.it Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@ziobuddalabs.it JABBER: michel@ziobuddalabs.it
-- [ Drupal support list | http://lists.drupal.org/ ]
Right now I have this:
<?php if (arg(1) != '39'): ?> <div> Content </div> <?php endif; ?>
This works just fine but when i try to add in a second arg(1) and OR statement it doesn't work. Any ideas?
On Sun, Jul 11, 2010 at 9:16 PM, Chris McCreery chris.mccreery@gmail.comwrote:
I get node/10 so then arg(1) would be 10 correct? If I test for just arg(1) != "10" it works but when i try to combine multiple conditions doesn't work for me. I'm definitely not a php programmer so I'm sure it's a stupid error on my part.
Thanks,
On Sun, Jul 11, 2010 at 8:51 PM, Michel Morelli michel@ziobuddalabs.itwrote:
Chris McCreery ha scritto:
Hi Michel I am testing for this in my page.tpl.php trying to display a certain <div> when arg(1) doesn't equal 27 or 39.
Ok, for test at the top of page.tpl.php file write
echo $_GET['q'];
and see which is arg(1)
M.
-- Michel 'ZioBudda' Morelli michel@ziobuddalabs.it Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@ziobuddalabs.it JABBER: michel@ziobuddalabs.it
-- [ Drupal support list | http://lists.drupal.org/ ]
-- Chris McCreery
I noticed that you have wrong syntax on this line: <?php if (arg(1) != "27") || (!$is_front): ?> It should be <?php if (arg(1) != "27" || !$is_front): ?>
# Hendry
On Mon, Jul 12, 2010 at 9:20 AM, Chris McCreery chris.mccreery@gmail.com wrote:
Right now I have this:
<?php if (arg(1) != '39'): ?>
<div> Content </div> <?php endif; ?> This works just fine but when i try to add in a second arg(1) and OR statement it doesn't work. Any ideas?
Perhaps multiple calls to arg shifts..
How about this:
$a = arg(1); if(($a != 27) || ($a != 39) || !$is_front){ ?> <div>You won't see this on node/27, node/39 or the front page.</div> <?php }
On 12 July 2010 12:14, Hendry hendry.htc@gmail.com wrote:
I noticed that you have wrong syntax on this line: <?php if (arg(1) != "27") || (!$is_front): ?> It should be <?php if (arg(1) != "27" || !$is_front): ?>
# Hendry
On Mon, Jul 12, 2010 at 9:20 AM, Chris McCreery chris.mccreery@gmail.com wrote:
Right now I have this:
<?php if (arg(1) != '39'): ?>
<div> Content </div> <?php endif; ?> This works just fine but when i try to add in a second arg(1) and OR statement it doesn't work. Any ideas?
-- [ Drupal support list | http://lists.drupal.org/ ]
A ha scritto:
Perhaps multiple calls to arg shifts..
How about this:
$a = arg(1); if(($a != 27) || ($a != 39) || !$is_front){ ?>
<div>You won't see this on node/27, node/39 or the front page.</div> <?php }
I think that you will see this div always :D For example: $_GET['q'] = 27 so arg(1) = 27 and $front is node/10
($a != 27) false OR ($a != 39) true OR (!$is_front) true so FALSE OR TRUE OR TRUE = TRUE
In any case a nid is always != 27 OR !39 or != 10.
Or am i wrong ?
M.
Chris McCreery wrote:
Right now I have this:
<?php if (arg(1) != '39'): ?>
<div> Content </div> <?php endif; ?>
This works just fine but when i try to add in a second arg(1) and OR statement it doesn't work. Any ideas?
I made this mistake often when I first started programming. Use AND and not OR when using !=. Or you could use the alternative method as show below.
<?php if (arg(1) != '39' && arg(1) != '49'): ?> <div> Content </div> <?php endif; ?>
ALTERNATIVE:
<?php if (!(arg(1) == '39' || arg(1) == '49')): ?> <div> Content </div> <?php endif; ?>
That was the problem. I need the ! statement at the beginning of both conditions. So in the end the following did the trick: <?php if (!(arg(1) == '39' || arg(1) == '49')): ?> <div> Content </div> <?php endif; ?>
Thank you so much for all your help everyone.
On Mon, Jul 12, 2010 at 8:17 AM, Earnie Boyd earnie@users.sourceforge.netwrote:
Chris McCreery wrote:
Right now I have this:
<?php if (arg(1) != '39'): ?>
<div> Content </div> <?php endif; ?>
This works just fine but when i try to add in a second arg(1) and OR statement it doesn't work. Any ideas?
I made this mistake often when I first started programming. Use AND and not OR when using !=. Or you could use the alternative method as show below.
<?php if (arg(1) != '39' && arg(1) != '49'): ?>
<div> Content </div> <?php endif; ?>
ALTERNATIVE:
<?php if (!(arg(1) == '39' || arg(1) == '49')): ?>
<div> Content </div> <?php endif; ?>
-- Earnie -- http://progw.com
-- http://www.for-my-kids.com
[ Drupal support list | http://lists.drupal.org/ ]