Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Contemplative Computing

    (@contemplative-computing)

    I got it! Created a template following the instructions in “other notes”

    Here’s what it looks like:

    <?php
    /*
    Plugin Name: List Category Posts - Template
    Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
    Description: Template file for List Category Post Plugin for WordPress which is used by plugin by argument template=value.php
    Version: 0.9
    Author: Radek Uldrych & Fernando Briano
    Author URI: http://picandocodigo.net http://radoviny.net
    */
    
    /* Copyright 2009  Radek Uldrych  (email : verex@centrum.cz), Fernando Briano (http://picandocodigo.net)
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    */
    
    /**
     * The format for templates changed since version 0.17.
     * Since this code is included inside CatListDisplayer, $this refers to
     * the instance of CatListDisplayer that called this file.
     */
    
    /* This is the string which will gather all the information.*/
    $lcp_display_output = '';
    
    // Show category link:
    $lcp_display_output .= $this->get_category_link('strong');
    
    $lcp_display_output .= '<form name="this.form">';
    
    //Add 'starting' tag. Here, I'm using an unordered list (ul) as an example:
    $lcp_display_output .= '<select name="URL" onchange="window.location.href=this.form.URL.options[this.form.URL.selectedIndex].value">';
    
    /**
     * Posts loop.
     * The code here will be executed for every post in the category.
     * As you can see, the different options are being called from functions on the
     * $this variable which is a CatListDisplayer.
     *
     * The CatListDisplayer has a function for each field we want to show.
     * So you'll see get_excerpt, get_thumbnail, etc.
     * You can now pass an html tag as a parameter. This tag will sorround the info
     * you want to display. You can also assign a specific CSS class to each field.
     */
    
    foreach ($this->catlist->get_categories_posts() as $single):
        //Start a List Item for each post:
    
        $permalink .= get_permalink($single->ID);
    
        $lcp_display_output .= '<option value="' .$permalink. '">';
    
        //Show the title and link to the post:
        $lcp_display_output .= $this->get_post_title($single);
    
        //Show comments:
        $lcp_display_output .= $this->get_comments($single);
    
        //Show date:
        $lcp_display_output .= ' ' . $this->get_date($single);
    
        //Show author
        $lcp_display_output .= $this->get_author($single);
    
        //Custom fields:
        $lcp_display_output .= $this->get_custom_fields($this->params['customfield_display'], $single->ID);
    
        //Post Thumbnail
        $lcp_display_output .= $this->get_thumbnail($single);
    
        /**
         * Post content - Example of how to use tag and class parameters:
         * This will produce:<p class="lcp_content">The content</p>
         */
        $lcp_display_output .= $this->get_content($single, 'p', 'lcp_content');
    
        /**
         * Post content - Example of how to use tag and class parameters:
         * This will produce:<div class="lcp_excerpt">The content</div>
         */
        $lcp_display_output .= $this->get_excerpt($single, 'div', 'lcp_excerpt');
    
        //Close li tag
        $lcp_display_output .= '</option>';
    endforeach;
    
    $lcp_display_output .= '</select>';
    $lcp_display_output .= '</form>';
    $this->lcp_output = $lcp_display_output;

    this looks awesome but i am new to this stuff and was wondering where i would put the cat id to make it pull from the specific cat

    Thread Starter Contemplative Computing

    (@contemplative-computing)

    Just follow the normal instructions for the shortcode with a category name and include the template field with whatever the name of your template file is. I called this one dropdown.php.

    So to use it to show the last five posts from the “fruit” category would be:

    [catlist name=fruit numberposts=5 template=dropdown]

    I wanted ALL my posts in that category in an alphabetical list so I used:

    [catlist name=fruit numberposts=5 orderby=title order=ASC numberposts=-1 template=dropdown]

    Anyone still out there?

    I could really use some help.

    So I did everything you said, Contemplative, and was pleasantly surprised to see the dropdown menu on my sidebar EXACTLY the way I wanted it to look using this shortcode in a text widget for the sidebar:

    ‘[catlist name=major-arcana numberposts=22 template=dropdown orderby=date order=asc]’

    Now I’m just having linking problems.

    I should mention I’m using a local MAMP but I didn’t think that would matter, anyway here’s what’s happening:

    URL of Page (post) I start on:
    [IMG]http://i.imgur.com/9w1YwrP.png[/IMG]

    What dropdown looks like on page:
    [IMG]http://i.imgur.com/9wrddBH.png[/IMG]

    What I’m about to click:
    [IMG]http://i.imgur.com/9wrddBH.png[/IMG]

    And the URL it takes me to, which leaves the page totally blank:
    [IMG]http://i.imgur.com/5CA2x3g.png[/IMG]

    Sorry for double post, wanted it to look right (hate how you can’t edit a post)

    Anyone still out there?

    I could really use some help.

    So I did everything you said, Contemplative, and was pleasantly surprised to see the dropdown menu on my sidebar EXACTLY the way I wanted it to look using this shortcode in a text widget for the sidebar:

    [catlist name=major-arcana numberposts=22 template=dropdown orderby=date order=asc]

    Now I’m just having linking problems.

    I should mention I’m using a local MAMP but I didn’t think that would matter, anyway here’s what’s happening:

    URL of Page (post) I start on:

    What dropdown looks like on page:

    What I’m about to click:

    And the URL it takes me to, which leaves the page totally blank:

    Thread Starter Contemplative Computing

    (@contemplative-computing)

    The output URL is generated by the first two lines of the loop in the template, specifically:

    $permalink .= get_permalink($single->ID);
    
    $lcp_display_output .= '<option value="' .$permalink. '">';

    Whatever is going wrong is probably happening there.

    I would first test the output of get_permalink($single->ID), which may not be working properly on your local server. If that function is outputting the permalink correctly, then something weird is going on with the way your browser is interpreting the options. I might try another browser to rule out a client-related error.

    That’s all I can think of right now. Hope you get it worked out!

    I tried a few other browsers no luck.

    How do I test the output?

    Thanks for the response, btw.

    Thread Starter Contemplative Computing

    (@contemplative-computing)

    If you aren’t comfortable with troubleshooting the PHP, then I’d recommend trying this code on a live server before fretting about it further. It might well have to do with the way permalinks are formed on a localhost. Who knows? I have never developed that way.

    Also, it might be worth checking/resetting your permalink settings.

    Finding another way to test the output of that string in this case is slightly complicated. Take the easy steps first. 🙂

    Will do, thanks. I may stop by again if I get it up live and still doesn’t work.

    Ciao!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Output as Dropdown?’ is closed to new replies.