ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

MSM / category_group problem on 2nd site?

August 11, 2010 8:45am

Subscribe [3]
  • #1 / Aug 11, 2010 8:45am

    LucPestille

    146 posts

    Hi,
    I’ve got 2 sites running on MSM - the first site has a weblog and categories/groups set up, and on the 2nd site, I’m trying to pull those category groups out using:

    <select>
    {exp:weblog:categories site="default_site" weblog="gallery" style="linear" category_group="17"}
        <option value="{path=gallery}">{category_name}</option>
    {/exp:weblog:categories}
    </select>

    However, it doesn’t want to show anything. The category group does exist (removing category_group=“17” from the exp:weblog:categories shows all the categories) - any ideas? Is this a known limit, or bug?

    This is on an older build (1.6.8 Build 20090723) - updating it is next on my list, but not critical up to this point…

    Thanks,

  • #2 / Aug 12, 2010 5:58am

    John Henry Donovan

    12339 posts

    Luc,

    What happens if you remove the site= parameter?

  • #3 / Aug 12, 2010 7:29am

    LucPestille

    146 posts

    From what I remember, it removed all the options. I did it another way in the end, as I couldn’t get it to work as I wanted through normal tags;

    <form id="filters">
    
    <?php
    //enable php/ee bridges
    global $IN;
    global $DB;
    
    $last_segment = (! isset($IN->SEGS[sizeof($IN->SEGS)])) ? '0' : $IN->SEGS[sizeof($IN->SEGS)];
    if(  $last_segment[0] == "P" ){
    $last_segment = (! isset($IN->SEGS[sizeof($IN->SEGS)])) ? '0' : $IN->SEGS[sizeof($IN->SEGS)-1];
    }
    
    //get child categories 
    
    //get category parents
    $parent_categories = array("17", "18");
    reset($parent_categories);
    
    //loop each parent
    foreach ($parent_categories as $key => $value) {
    
        //query the database
        $query = $DB->query("SELECT cat_id as category_id, cat_name AS category_name, cat_url_title AS category_url_title FROM exp_categories WHERE parent_id = '".$value."'");
    
        if ($query->num_rows > 0)
        {
            if ( $value == "17" ){ echo "<label>Pick a genre</label><select class='filter_category'><optgroup label='Genre'><option></option>"; }
            if ( $value == "18" ){ echo "<label><em>OR</em> material</label><select class='filter_category'><optgroup label='Material'><option></option>"; }
            
            //get each child category and add to, or remove from URL
            foreach($query->result as $row)
            {
                
            //get category url title
            $cat_url = $row['category_url_title'];
            $cat_name= $row['category_name'];
    
            $cat_selected = "";
            if( $last_segment == $cat_url ){
                $cat_selected = "selected";
            }else{
                $cat_selected = "";
            }
    
                echo "<option ". $cat_selected ." value='{homepage}gallery/category/" . $cat_url. "/'>" . $cat_name. "</option>";
    
            }
            echo "</optgroup></select>";
        }
    }
    ?>
    
    
                    <label><em>OR</em> <a href="http://{homepage}gallery/" title="View all">view all</a></label>
    
                </form>
  • #4 / Aug 12, 2010 3:48pm

    Ingmar

    29245 posts

    So, you’re up and running? Just making sure.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases