• Hi,

    I am currently designing a new Theme using ZimpleZa as my base.

    I am planning to design a Desktop-like Theme with a Background and every WordPress- Content (Header, Index, Footer,…) in one or multiple Javascript- Popup boxes.

    I managed to put the Header and Footer in 2 different Popup boxes aleady. But I am currently having some Problems with the sidebar (didn’t try index and comments yet). Somehow the following code does not only give me no results, it crashed my whole javascript Code:

    <script language="javascript">
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    </script>

    I think the reason is because the output is some kind of Array?
    The “single- string-” WordPress functions like “bloginfo(‘name’);” work just fine …

    BTW: I am using the Popup-Box Javascript from Scriptasylum

    BTW2: I tried to google and search in the forums, but couldn’t find anything yet …

Viewing 6 replies - 1 through 6 (of 6 total)
  • First of all, don’t use wp_list_cats(), as it’s been deprecated. Use wp_list_categories() instead.

    Second, the code you have there doesn’t make sense: wp_list_cats() (and wp_list_categories()) outputs the categories as HTML list items, not JavaScript code. If you want a list of categories, just leave off the <script> tags.

    Thread Starter haskar

    (@haskar)

    Thank you for your answer filosofo 🙂

    you are right, my code doesn’t make any sense. It was actually some kind of dummy code.

    Here is some real code from my header file:

    <script language="javascript">
    <!--
    new popUp(250 , 0 , 950 , 150 , "header" , "<div id=\"header\"><h1><a href=\"<?php echo get_settings('home'); ?>/\"><?php bloginfo('name'); ?></a></h1><p class=\"description\"><?php bloginfo('description'); ?></p></div>" , "white" , "black" , "10pt sans-serif" , "Header" , "#0F72BB" , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false ,'<?php bloginfo('template_url'); ?>/images/min.gif','<?php bloginfo('template_url'); ?>/images/max.gif','<?php bloginfo('template_url'); ?>/images/close.gif','<?php bloginfo('template_url'); ?>/images/resize.gif');   
    
    showbox('header');
    //-->
    </script>

    As you can see, the 6th argument for the popUp() function is a string with HTML Code.

    The PopUp Code for the sidebar looks like this (simplified)

    <script language="javascript">
    <!--
    new popUp(250 , 0 , 950 , 150 , "header" , "<?php wp_list_categories('sort_column=name&optioncount=1&hierarchical=0'); ?>" , "white" , "black" , "10pt sans-serif" , "Header" , "#0F72BB" , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false ,'<?php bloginfo('template_url'); ?>/images/min.gif','<?php bloginfo('template_url'); ?>/images/max.gif','<?php bloginfo('template_url'); ?>/images/close.gif','<?php bloginfo('template_url'); ?>/images/resize.gif');   
    
    showbox('header');
    //-->
    </script>

    This should list all of the categories in a popUp- Box. But the Code doesn’t work. Even if I set ‘echo=0&style=none’ and so on

    That’s probably because wp_list_categories uses double quotation marks for its attributes, and you have that markup in double quotation marks for the JavaScript function call:

    If you look at the markup, it will probably be like this:
    new popUp(250 , 0 , 950 , 150 , "header" , "<li class=" Whoops!

    Wrap the HTML in single quotation marks instead:

    new popUp(250 , 0 , 950 , 150 , "header" , '<?php wp_list_categories('sort_column=name&optioncount=1&hierarchical=0'); ?>'

    Thread Starter haskar

    (@haskar)

    thank you so much filosofo!!

    although you solution didn’t work out for me, I begant to rethink the “”” and “‘” idea and tried this one:

    new popUp(250, 150, 200, 600, "sidebar" , <?php wp_list_categories('hide_empty=0&sort_column=name&optioncount=1&hierarchical=1'); ?> , "white" , "black" , "10pt sans-serif" , "Sidebar" , "#0F72BB" , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false ,'<?php bloginfo('template_url'); ?>/images/min.gif','<?php bloginfo('template_url'); ?>/images/max.gif','<?php bloginfo('template_url'); ?>/images/close.gif','<?php bloginfo('template_url'); ?>/images/resize.gif');

    … and it worked 🙂

    Thread Starter haskar

    (@haskar)

    I have another problem to the same topic:

    new popUp(10, 10, 400, 400, "Index2" , <?php the_content('Read the rest of this entry &raquo;'); ?>, "white" , "black" , "9pt sans-serif" , "Index" , "#0F72BB" , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false ,'<?php bloginfo('template_url'); ?>/images/min.gif','<?php bloginfo('template_url'); ?>/images/max.gif','<?php bloginfo('template_url'); ?>/images/close.gif','<?php bloginfo('template_url'); ?>/images/resize.gif');

    does not seem to work. Do you gave any clues about the return Value of the the_content Function?
    I checked: http://codex.wordpress.org/Template_Tags/the_content and http://codex.wordpress.org/Function_Reference/get_the_content

    I also tried

    new popUp(10, 10, 400, 400, "Index2" , "<?php the_content('Read the rest of this entry &raquo;'); ?>",[...]);

    and

    new popUp(10, 10, 400, 400, "Index2" , '<?php the_content('Read the rest of this entry &raquo;'); ?>',[...]);

    Thread Starter haskar

    (@haskar)

    Btw,

    I am having similar problems with wp_list_pages() and wp_get_archives()

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Javascript and php’ is closed to new replies.