WordPress.org

Ready to get started?Download WordPress

Forums

Please help; WP forums giving me trouble (28 posts)

  1. 4evrblu
    Member
    Posted 7 years ago #

    I am trying to post a very unsual thread regarding http://totalphysiqueonline.com/ and trouble I am having validating the individual pages. When I try to paste the code, it screw up the topic and the topic gets closed or the rss feed to the topic becomes invalid.

    http://totalphysiqueonline.com/ is not validating the individual pages, and I need someone to go there and use the validation tool at the top right within the meta section to see what I am talking about. The splash page validates just fine. But when you link to any of the seven pages I created, via the buttons up top, the code that controls them which utilizes li class="level1" and li class="current" breaks down horribly.

    The php code that controls is in the header, of course. It seems to be valid code, and obviously works to create the header and its buttons, and even validates the splash page, but there is something amiss that is breaking the code once you link to the pages, causing the UL and LI tags to loose values between the class= 'tags' so that class='' tag values shows up empty. Does that make sense?

    I am sorry for the poorly constructed topic, but clearly I need some coaching as to how to paste code for people to look at.

    And what the heck is a backtick? Is that geek-speek for a backward slash?

  2. 4evrblu
    Member
    Posted 7 years ago #

    OK I search for backtick and I found out what the hell they are. No wonder I didn't know what they were. I have never, ever used it. Turns out that other people in WP are in the dark as well.

    I will try to post the code using the back tick

    <?php if (is_page()) { $highlight = ""; } else {$highlight = "current"; } ?>
    <div id="mainmenu">
    <ul class="level1">
    <li class="<?php echo $highlight; ?>"><a href="<?php echo get_settings('home'); ?>"><?php _e('Home','andreas09'); ?></a></li>
    <?php
    if(function_exists("wp_andreas09_nav")) {
    wp_andreas09_nav("sort_column=menu_order&list_tag=0&show_all_parents=1&show_root=1");
    }
    ?>
    </div>

  3. 4evrblu
    Member
    Posted 7 years ago #

    OK that worked.

    WHEW

    Finally.

    The code I pasted is from the header.php file.

  4. Chris_K
    Member
    Posted 7 years ago #

    As an aside, if you make a post and it doesn't show up, don't try posting it 12 more times.

    Instead, just wait and allow a moderator to remove it from the spam traps.

    Thanks.

    {refer to http://wordpress.org/support/topic/97707?replies=1}

  5. moshu
    Member
    Posted 7 years ago #

    If you want to post long(er) code - always use http://wordpress.pastebin.ca and post back the URI.

  6. 4evrblu
    Member
    Posted 7 years ago #

    Handy I am sorry, thank you. I appreciate it. Sorry for the successive posts.

    Does anyone have a solution to the aboove issue by any chance?

  7. Kafkaesqui

    Posted 7 years ago #

    First:

    http://validator.w3.org/check?uri=http%3A%2F%2Ftotalphysiqueonline.com%2Fsponsors%2F

    seems to have no problem with your Pages.

    The error you're getting from the other validator is due to a stricter interpretation of the attribute=value construct in a tag, in that the value should not be empty (or to use their semantics, its min(imum)Length cannot be less than 1).

    To avoid it, you can always change your code to:

    <?php if (is_page()) { $highlight = "is_page"; } else {$highlight = "current"; } ?>

    I'm not 100% certain, but I do believe a class does not actually need to be declared in your css to be considered 'valid.'

  8. 4evrblu
    Member
    Posted 7 years ago #

    Well, if anyone has a suggestion please chime in. Otherwise if I find the solution myself I will let you know.

  9. Kafkaesqui

    Posted 7 years ago #

    Ahem...

  10. vkaryl
    Member
    Posted 7 years ago #

    Really, the only validator one should worry about is http://validator.w3.org/....

  11. 4evrblu
    Member
    Posted 7 years ago #

    OK thanks guys, lemme try this...

  12. 4evrblu
    Member
    Posted 7 years ago #

    That does not fix the issue. Hmmm.

    The html output of the code above is more or less identical to the previous one:

    <div id="mainmenu">
    <ul class="level1">
    <li class="is_page"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class=' current' ><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/sponsors/' title='Sponsors'>Sponsors</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/body-buddy/' title='Body Buddy'>Body Buddy</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/spotlight/' title='Spotlight'>Spotlight</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/photographic-phun/' title='PictureThis'>PictureThis</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/contact/' title='Contact'>Contact</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/disclaimer/' title='Disclaimer'>Disclaimer</a></li>
    </ul></div>

    It's the oddest thing. Two things are happening:

    1) the values should be li class="level1" unless its the current page. Instead the values are being changed to li class='' which reveals the other oddity:
    2) the double quotes are being replaced with single quotes and extra spaces are being added for li class=' current'

    What the heck is causing that?

    I would still like to point out that the splash home page uses the same php call tags and it works, yeilding the following html::

    <div id="mainmenu">
    <ul class="level1">
    <li class="current"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/sponsors/' title='Sponsors'>Sponsors</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/body-buddy/' title='Body Buddy'>Body Buddy</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/spotlight/' title='Spotlight'>Spotlight</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/photographic-phun/' title='PictureThis'>PictureThis</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/contact/' title='Contact'>Contact</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/disclaimer/' title='Disclaimer'>Disclaimer</a></li>
    </ul></div>

  13. 4evrblu
    Member
    Posted 7 years ago #

    For the record I think the stricter interpretation makes better sense in this particular instance.

    And Kafka, the css does contain a style called level1. Its declared. And its there for a reason.

    I think the issue is here:
    <?php if (is_page()) { $highlight = ""; } else {$highlight = "current"; } ?>

    It should be :

    <?php if (is_page()) { $highlight = "level1"; } else {$highlight = "current"; } ?> Shouldn't it?

    But even what I change it to that, the class= does not assume the value of highlight = "level1", and instead morphs to empty once a page link is clicked.

  14. Kafkaesqui

    Posted 7 years ago #

    1. No limit I'm aware of. All the urls in it triggered Akismet (spam tool). I've de-spammed your post.

    2. Whatever interpretation (and validation tool) you go with is your choice.

    3. Using 'level1' as a class (for both the ul and li tags), or something different, is again up to you. I was merely pointing out the empty value for $highlight (and so the class attribute) was the cause of the error.

    4. I see this on your Pages at present:

    <li class="is_page"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class='' ><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>

    The class value for the About Page (as well as the others) is also a problem, and this is apparently generated by wp_andreas09_nav() (a function from the theme?).

    5. Please, call me Kaf.

  15. 4evrblu
    Member
    Posted 7 years ago #

    Hi Kaf, yeah I think it's clearly a them issue. Here is the function you are referencing:

    <?php
    if(function_exists("wp_andreas09_nav")) {
    wp_andreas09_nav("sort_column=menu_order&list_tag=0&show_all_parents=1&show_root=1");
    }
    ?>

    I believe this is for pages that have sub pages? Not sure.

    As you can see by the html output, for some reason the php does not break down at the splash page level. It begins to be wonky at the moment a page gets clicked. Andreas06 (a theme I have but do not use) uses a very similar php call. It looks like this:

    <?php
    if (is_page()) { $highlight = "page_item"; } else { $highlight = "page_item current_page_item"; } ?>
    <div id="nav">
    <ul>
    <li class="<?php echo $highlight; ?>"><a href="<?php echo get_settings('home'); ?>"><?php _e('Home','andreas06'); ?></a></li>
    <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=' ); ?>
    </ul>
    </div>

    You will notice that { $highlight = "page_item"; } is coded using a value for highlight. This php works in that theme. I tried it and all the pages work and the html output does not break down as it does with andreas09.

    Man I am sorry to be bugging you guys with this, but I am very grateful for the help!

  16. 4evrblu
    Member
    Posted 7 years ago #

    Anyway, I know where the issue is showing up. I know what code to be looking at. What I do not understand is why it is happening and how to fix it.

  17. 4evrblu
    Member
    Posted 7 years ago #

    I have not yet heard from the author of the theme. So, as far as I am concerned, the topic remains unresolved. I have tweaked and played with the code and I am unable to get the matter resolved. Still could use some assistance :)

    Would anyone care to log into my site? Perhaps poke around a bit. Moderators ideally.

    Also, can the moderators change the title of this topic to something more appropriate? Such as PHP breaking down in individual pages, or something like that?

    Thanks

  18. Ainslie
    Member
    Posted 7 years ago #

    Yes the code is a little buggy as it leaves an empty class in places but it does validate on http://validator.w3.org.

    Try validating the theme here: http://dev.webgazette.co.uk

  19. Ainslie
    Member
    Posted 7 years ago #

    Ok I have emailed you and updated functions.php that should insert a class if one wasn't previously set.

    This should fix the problem.

    Let me know if it works and I update the theme.

  20. Ainslie
    Member
    Posted 7 years ago #

    I would also change <?php if (is_page()) { $highlight = ""; } else {$highlight = "current"; } ?>

    to

    <?php if (is_page()) { $highlight = "level1"; } else {$highlight = "current"; } ?>

  21. 4evrblu
    Member
    Posted 7 years ago #

    Ainslie, thank you. Actually, I did try <?php if (is_page()) { $highlight = "level1"; } else {$highlight = "current"; } ?> yesterday several times. Of course, with the working functions.php, it was doomed to fail. Let me check my mail and I will come back here and let you know is this addressed the issue.

  22. 4evrblu
    Member
    Posted 7 years ago #

    Hi Ainslie. I just installed your new funtions.php and I think we have made some progress. Here is what the current html outpout reads like:

    <div id="mainmenu">
    <ul class="level1">
    <li class="level1"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class='page_item' ><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>
    <li class='current' ><a href='http://totalphysiqueonline.com/sponsors/' title='Sponsors'>Sponsors</a></li>
    <li class='page_item' ><a href='http://totalphysiqueonline.com/body-buddy/' title='Body Buddy'>Body Buddy</a></li>
    <li class='page_item' ><a href='http://totalphysiqueonline.com/spotlight/' title='Spotlight'>Spotlight</a></li>

    ...etc

    Is that what you were looking for? If so, then the issue is resolved.

    However, I will admit that what I was expecting to see was this:

    <div id="mainmenu">
    <ul class="level1">
    <li class="level1"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class='level1' ><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>
    <li class='current' ><a href='http://totalphysiqueonline.com/sponsors/' title='Sponsors'>Sponsors</a></li>
    <li class='level1' ><a href='http://totalphysiqueonline.com/body-buddy/' title='Body Buddy'>Body Buddy</a></li>
    <li class='level1' ><a href='http://totalphysiqueonline.com/spotlight/' title='Spotlight'>Spotlight</a></li>

    ...etc

    Thanks for doing so much work to address this. Do you feel like the adjusted html output is what you are looking for?

    You will also notice that in the corrected adjusted output, the functions.php has created this:

    <li class='page_item' ><a instead of
    <li class='page_item'><a

    In other words it has an extra space inserted between the last quote tick and the bracket for <li class='page_item' ><a

  23. Ainslie
    Member
    Posted 7 years ago #

    That bit of code just sets a the variable "$highlight" for the link to home as it is manually inserted in the menu because the list pages function doesn't add the home page link.

    The rest of the page menu is in the functions.php.

    You should now see that the classes are not empty and your validation should be ok?

  24. 4evrblu
    Member
    Posted 7 years ago #

    Hi.

    Yes the class is not empty now, and shows <li class='page_item' ><a

    but I was curious, so I backed up functions and went inside funtions.php and found this code around line 302 :

    $css_class = 'page_item';
    }
    echo "<li class='" . $css_class . "' ><a href='" . get_page_link($page_id) . "' title='" . wp_specialchars($title) . "'>" . $title . "</a></li>n";
    }

    as an experiment, I changed it to

    $css_class = 'level1';
    }
    echo "<li class='". $css_class ."'><a href='" . get_page_link($page_id) . "' title='" . wp_specialchars($title) . "'>" . $title . "</a></li>n";
    }

    I also reduced the extra space from '" . to '". and this "' > to this "'>

    Now the html output reads as follows:


    <ul class="level1">
    <li class="level1"><a href="http://totalphysiqueonline.com">Home</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/about/' title='About'>About</a></li>
    <li class='current'><a href='http://totalphysiqueonline.com/sponsors/' title='Sponsors'>Sponsors</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/body-buddy/' title='Body Buddy'>Body Buddy</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/spotlight/' title='Spotlight'>Spotlight</a></li>
    <li class='level1'><a href='http://totalphysiqueonline.com/picturethis/' title='PictureThis'>PictureThis</a></li>

    etc...

    is this more of what we want and did I go about it the wrong way?

  25. Ainslie
    Member
    Posted 7 years ago #

    The class used is totally irrelavant as there is no corresponidng style defined. It was just a value to output so that your site validated as you wanted. You can change it to whatever you prefer as long as it doesn't clash with something in the css that is going to mess things up.

  26. 4evrblu
    Member
    Posted 7 years ago #

    Hi Ainslie.

    that is interesting, because I checked the CSS file a few days ago and level1 is declared in it. And here is what it is:

    #mainmenu ul.level1 {
    border-top: 1px solid #fff;
    border-bottom: 1px solid #fff;
    }

    So it seemed to me to be important. :)

    Also, what line of code in the functions.php file is causing the values to assume single verses double quotes?

  27. Ainslie
    Member
    Posted 7 years ago #

    That is an <ul> tag with class "level1" and not a <li> tag with class "level1" and so has no effect. In other words the css is targeted at the <ul> only.

  28. 4evrblu
    Member
    Posted 7 years ago #

    OK :) thank you.

    I would also like to know what line of code is forcing the single quotes. Sorry, but I would just like to know :)

Topic Closed

This topic has been closed to new replies.

About this Topic