Jump to content

Php if statemant help needed


nocniagenti

Recommended Posts

OK friends I need a small if statemant to help me change width of the div's

the explanation should be like this

 

if  user2 and user3 modules are published (this are 2 horizontal modules

that are placed inside a div #mid width=950px )

 

user2 widht= 530px

user3 width=390px

 

if only user2 module is  published

 

user2 width=950px

 

and finaly if only user3 module is  published

 

user3 width=950px

 

this is what I have so far and only the first statmeant is working like it shold.

the other 2 always stay at  532px or 390px depends if user3 or user2 is published only

 

 


<?php 
$newsflash = 0;
$banner= 0 ;
if (mosCountModules('user2')) $banner++; 
if (mosCountModules('user3')) $newsflash++;
if (( $newsflash == 1 ) || ( $banner == 1 )) {
    $newsflashdivwidth = '390px';
    $bannerwidth = '532px';
     } else if (( $banner == 1 ) || ( $newsflash == 0 )) { 
    $bannerwidth = '950px';
    } else if (( $banner == 0 ) || ( $newsflash == 1 )) {
    $newsflashdivwidth = '950px';
?>

 

and this is the call for user2 and user3

 

<!-- NEWSFLASH MODULES -->
    <?php if (mosCountModules('user2') || mosCountModules('user3')) { ?>
        <div id="midsh"> 
        <div id="mid"><?php if (mosCountModules('user2')) { ?>
        <div id="banner" style="width:<?php echo $bannerwidth ?>;"> 
        <?php mosLoadModules ( 'user2' ); ?></div><?php } ?> 
        <?php if (mosCountModules('user3')) { ?>
        <div id="newsflash" style="width:<?php echo $newsflashdivwidth ?>;">
        <?php mosLoadModules ('user3');?></div><?php } ?> 
        </div>
        </div><?php } ?>

 

thank you

Link to comment
Share on other sites

love you guys

both of you where right

the last post made it work

code looks like this now

 

<?php
$newsflash = 0;
$banner= 0 ;
if (mosCountModules('user2')) $banner++;
if (mosCountModules('user3')) $newsflash++;
if (( $newsflash == 1 ) && ( $banner == 1 )) {
    $newsflashdivwidth = '390px';
    $bannerwidth = '532px';
     } elseif (( $banner == 1 ) && ( $newsflash == 0 )) {
    $bannerwidth = '946px';
    } elseif (( $banner == 0 ) && ( $newsflash == 1 )) {
    $newsflashdivwidth = '946px';


}
?>

 

it was suposed to be && not ||

 

thank you!!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.