• hey,

    basically I have a menu using jquery that reads if a page says “current” in the class. if it does it highlights the current page with a tab.
    unfortuantely on posts, none of the pages are current, the menu looks like crap.

    What im trying to do is where I originally call the menu in the header, just do a check to see if im on a post. If i am on a post (where the menu doesnt show up, then just find/replace the menu to have current in there.

    When I use this code though, nothing happens. the code within the html doesnt have current.

    <?
    $menutest = wp_list_pages("title_li=&exclude=".get_option("si_exclude_pages_from_menu")); 
    
    // force tabs on single post and order form
    if( is_single() ) {
    	$menutest = str_replace("page_item page-item-501", "page_item page-item-501 current", $menutest);
    	} else {
    
    	}
    	echo $menutest;
    ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter zesty1

    (@zesty1)

    even if the if statement is wrong (which it might be, im new to php), even without the if, but always doing str_replace, it still doesnt work

    Thread Starter zesty1

    (@zesty1)

    I think im not using str_replace right or something…..

    I also have this (which takes the input from a textarea) and is SUPPOSED to convert \r\n to
    .

    this is what i have in order in the php file

    It actually doesnt do shite though…. it sends me the information with \r\n still in there.

    store the value from previous form
    $homecontent=mysql_real_escape_string($_POST['HomeContent']);

    define function

    function format_html($content)
     {
      $content = "<p>" . str_replace("\r\n", "<br />", $content) . "";
      $content = "" . str_replace("<br /><br />", "</p><p>", $content) . "";
      return "" . str_replace("<br /><li>", "<li>", $content) . "";
     }

    save the variable with the supposed changes
    $homecontent = format_html("$homecontent</p>");

    after that i insert it into a database and then php mail() it to mysef… and it always is full of \r\n

    about your first post:
    you don’t seem to have a string in your variable:
    check the ‘echo’ parameter of ‘wp_list_pages’:

    echo
    (boolean) Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 1 (display the generated list items). Valid values:
    1 (True) – default
    0 (False)

    http://codex.wordpress.org/Template_Tags/wp_list_pages

    Thread Starter zesty1

    (@zesty1)

    you are a rockstar. that worked 🙂

    Thanks!

    Do you have any idea on the 2nd issue? i assume its cause its an ‘ojbect’ or something.. and not a string. how can i convert a large block of text to a string?

    your str_replace looks ok.
    i just wonder if the </p> in the following line is intentional:
    $homecontent = format_html("$homecontent</p>");

    and when you say, it is still full of \r\n at the end, does this mean that the other formatting (<p>, </p>, etc) is still mmissing ?

    Thread Starter zesty1

    (@zesty1)

    yes that is correct. it looks identical to the way it was stored as if the str replace didnt find anything

    the p is to close the tag and is intentional due to the way the script writes. i didnt write it myself i just got it from the php manual comments that someone else wrote and everyone said worked great.

    if you have any better ideas im all ears

    Thread Starter zesty1

    (@zesty1)

    any other ideas anyone?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘What’s wrong with this php? (simple question)’ is closed to new replies.