bigbenbuilders Posted September 3, 2009 Share Posted September 3, 2009 If my URL = this echo success... what I am trying to do with this script if the url is this then it will say this? but it doesnt? <?php if (stripos($_SERVER['REQUEST_URI'],'/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2/') !== false) {echo '"selected"';} ?> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 say selected sorry Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 I'm not entirely sure what you are saying, but I'm assuming you want to echo something if your URL is something. why dont you do if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') { echo '"selected"'; } ?? Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 im trying to replace with this <?php if (stripos($_SERVER['REQUEST_URI'],'/id=1/') !== false) {echo 'class="alumni_tab_1_on_index"';} ?> from this <td width="105"><a href="index.php?option=com_content&task=category§ionid=2&id=1&Itemid=37 " class="a_black text_10"> <div class="tab_1" onMouseOver="this.className='tab_1_on_index'" onMouseOut="this.className='tab_1_index'">giving</div> </a></td> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 sorry this is like this <td width="105"><a href="index.php?option=com_content&task=category§ionid=2&id=1&Itemid=37 " class="a_black text_10"> <div class="alumni_tab_1" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">giving</div> </a></td> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 mikesta707 that does produce the words selected but how do I embed the other code into it? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 well... just remove the backslashes and its fine... <?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) {echo 'class="alumni_tab_1_on_index"';} ?> just tested on my server. went to: http://localhost/text.php?id=1&poop=3 and it echoed what it was supposed to. IDK why you had those backslashes in there Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 its displaying this on the page class="alumni_tab_1_on_index" I want it to call the class from the css? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 oh... where do you want to call this class. whereever you want to call it, echo that in the HTML. its not that hard.. like <div class="<?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) {echo 'class="alumni_tab_1_on_index"';} ?>"> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 this is what I have with the full url in it and it is not working? <div class="<?php if (stripos($_SERVER['REQUEST_URI'],'http://cuaa.info/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') !== false) {echo 'class="alumni_tab_1_index"';} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div> Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 firstly, the Request URI var of the server array returns the local path, not the full path. if (stripos($_SERVER['REQUEST_URI'],'/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') !== false) but why are you using stripos... you should be just comparing them because it seems like you only want to do this when this exact URL is gone to... if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2'){ which is what i posted before... Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 thanks for all your help mikesta707...it displays the word alumni and when I roll over it the tab pops up but it is not up like it is supposed to be at the begining like it is returning a false? this is what I have <div class="<?php if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2'){echo 'class="alumni_tab_1_index"';} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div> Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 you are already writing class, so no need to write it twice echo 'class="alumni_tab_1_index"' should be echo 'alumni_tab_1_index'; Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 mikesta777 that worked perfect...one more question if it does not equal the url then how do I have it default to another echo? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 if (this){ //original stuff } else { echo "default echo"; } Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 dang I know I am close..now I get a blank page here is what I have <div class="<?php if (this){ ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2'){echo 'alumni_tab_1_index';}} else { echo "default echo"; } ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div> Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 haha When i wrote if(this) i meant your original of statement, not to actually wrap what you had with if(this) <div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';} else { echo "default echo"; } ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 you da man you da man... how do I get this in the echo because if false it would be tab1 onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'" Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 i dont quite understand, you want those to be tab1 when the same if statement above runs true. just put the ifstatement there <div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';} else { echo "default echo"; } ?>" onMouseOver="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') {echo 'tab1';} else { echo "default echo"; ?> '" onMouseOut="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') {echo 'tab1';} else { echo "default echo"; ?>'">alumni</div> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 if the if statement is false and when rolled over they are tab1 Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 if you want to affect multiple attributes I would suggest you preform the if statement before the output of the HTML, and store the attributes in variables. like if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') { $class = "alumni_tab_1_index"; $mouseOver="whatever'; $mouseOut = "whatever } else { $class = "default value"; etc. etc. } and in your html <div class="<?php echo $class; ?>" onMouseOver="this.className='<?php echo $mouseOver; ?>'" onMouseOut="this.className='a<?php echo $mouseOut; ?>'">alumni</div> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 k let me try that Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 mikeesta707 perfect but with just another little hitch the id=1 for that section will not change but the rest could and I need it to stay on when the id=1 regardless of the rest of the string...here is the code and it does work when I remove part of the string and switches... <? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') { $class = 'alumni_tab_1_index'; $mouseOver='alumni_tab_1_on_index'; $mouseOut = 'alumni_tab_1_index'; } else { $class = 'tab_1'; $mouseOver = 'tab_1_on'; $mouseOut = 'tab_1'; } ?> <div class="<?php echo $class; ?>" onMouseOver="this.className='<?php echo $mouseOver; ?>'" onMouseOut="this.className='<?php echo $mouseOut; ?>'">alumni</div> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 3, 2009 Author Share Posted September 3, 2009 for example the string could look like this and needs to stay on http://cuaa.info/index.php?option=com_content&task=category§ionid=1&id=5&Itemid=10 Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 3, 2009 Share Posted September 3, 2009 Oh, well why didn't you say that lol change your if too <?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) isn't that what you were trying to do in the beginning? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.