Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter codycuellar

    (@codycuellar)

    Oh the power of Google. Solved it finally using strpos(); function.

    Here’s the new working code:

    <?php
    			  $homeURL = ( $url == get_bloginfo('url').'/' ) ? 'current' : 'null';
    
    			  $workcheck = strpos($url, get_bloginfo('url').'/work');
    			  $workURL = ($workcheck === false) ? "null" : "current";
    
    			  $biocheck = strpos($url, get_bloginfo('url').'/bio');
    			  $bioURL = ($biocheck === false) ? "null" : "current";
    
    			  $contactcheck = strpos($url, get_bloginfo('url').'/contact');
    			  $contactURL = ($contactcheck === false) ? "null" : "current";
    		  ?>

    In the link class field I kept it as:
    <?php echo "$homeURL" ?>

    Thread Starter codycuellar

    (@codycuellar)

    I tried using >= and thought it solved it, but then I realized it was giving me really weird results and not actually doing what I thought it would do.

    Thread Starter codycuellar

    (@codycuellar)

    Excellent! Thank you, it works perfectly now after a bit of tweaking. However one more question regarding this topic (also sparked from one issue I was having). As I was testing the variables I just used echo to display the variables on screen so I could see what they were returning and for the longest time my $url and get_bloginfo(‘url’) appeared to be returning the exact same value, until I realized that the get_bloginfo didn’t put a / at the end, so my $homeURL kept returning “null”. I had to change it to get_bloginfo(‘url’).”/” so my $homeURL would return the result “current”.

    Now my question is, is there a way that I can make the $url check if it begins with a certain string and disregard anything that comes after it? For instance, if my custom permalinks start with http://www.site.com/blog for every post, I want the blog link in my nav bar to stay activated. When the function runs to assign the url to $url, it will read http://www.site.com/blog/category/year/month/post-title, but since it begins with http://www.site.com/blog I want $homeURL to still return true and give me the “current” value – and disregard whatever comes after such as the category, year, etc. So rather than == is there a “begins with” type of operator or is this going to be much more involved?

    Anyway here’s the final working code:

    <?php $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>
    		  <?php
                  $homeURL = ( $url == get_bloginfo('url').'/' ) ? 'current' : 'null';
    			  $workURL = ( $url == get_bloginfo('url').'/work' ) ? 'current' : 'null';
    			  $bioURL = ( $url == get_bloginfo('url').'/bio' ) ? 'current' : 'null';
    			  $contactURL = ( $url == get_bloginfo('url').'/contact' ) ? 'current' : 'null';
    		  ?>
          <div id="navbar">
            <ul id="navigation">
    
              <li id="navigation-1"><a href="<?php bloginfo('url') ?>/" title="home" class="<?php echo "$homeURL" ?>"><span>home</span></a></li>
              <li id="navigation-2"><a href="<?php bloginfo('url') ?>/work" title="work" class="<?php echo "$workURL" ?>"><span>work</span></a></li>
              <li id="navigation-3"><a href="<?php bloginfo('url') ?>/bio" title="bio" class="<?php echo "$bioURL" ?>"><span>bio</span></a></li>
              <li id="navigation-4"><a href="<?php bloginfo('url') ?>/contact" title="contact" class="<?php echo "$contactURL" ?>"><span>contact</span></a></li>
            </ul>
          </div><!-- navbar -->
    Forum: Themes and Templates
    In reply to: Text on image

    Try something like this:

    <div class="outerwrapper" style="width: 500px; height:200px; background: blue;">
      <div class="left" style="width: 50%; background:green; float: left;">
        <div class="contentleft" style="padding: 20px;">
          <img src="imagesource.jpg" />Content
        </div>
      </div>
      <div class="right" style="width: 50%; background:red; float: right;">
        <div class="contentright" style="padding: 20px;">
          <img src="imagesource.jpg" />Content
        </div>
      </div>
    </div>

    Granted, you’ll have to change all the values to match your site, but that basic set-up will give you a visual representation of what you’re going to get. I’d also suggest taking out all your css and putting it in a separate css document and linking your pages to it, it makes things much neater and easier to modify. Hope that helps!

Viewing 4 replies - 1 through 4 (of 4 total)