1

Here is what I am trying to do.

I am using Safecracker to do the add/edit posting, but when the user click on a checkbox, then go to edit the posting, the check box is not there.

I am using Gwcode Categories Plugin, outputting my categories as checkboxes because it has more feature and flexibility then the built in safecracker categories tag

GWCode Categories

        <ul>
        {exp:gwcode_categories group_id="9"} 
        <li>
    <input type="checkbox"  id="categories" name="category[]" value="{cat_id}" {checked} />
 <span>{cat_name}</span>    
 </li>
 {/exp:gwcode_categories}
</ul>

but when I use Safecracker

<ul>
     {categories}
      <li>&lt;input type="checkbox" name="category[]" id="categories" value="{category_id}" {checked} /&gt; 
<span>{category_name}</span> </li>
{/categories}
</ul>

the checkbox is there. why I cant just used the {checked} in the Gwcode Categories and why does it have to be in {categories}{/categories}

here is the code that I have right now and trying to do with safecracker

{exp:gwcode_categories group_id="9"} 
    {if has_children && parent_id == '0' }
        <!-- parent with children -->
        <li class="checkbox checkbox_parent">  
            <span><b>{cat_name}</b></span>
        </li>
    {if:elseif depth == 2}
        <!-- child at second level -->
        <li class="checkbox">  
            <input type="checkbox" id="categories" name="category[]" value="{cat_id}" checked="{checked}" />
            <span>{cat_name}</span>
        </li>
    {if:elseif depth == 3}
        <!-- child at third level -->
        <li class="checkbox">  
            <input type="checkbox"  id="categories" name="category[]" value="{cat_id}" checked="{checked}" />
            <span>{cat_name}</span>
        </li>
    {if:else}
        <!-- parent with no children -->
        <li class="checkbox_parent_nochild">
            <input type="checkbox"  id="categories" name="category[]" value="{cat_id}" checked="{checked}"  /> 
            <span>{cat_name}</span>
        </li>
    {/if}
{/exp:gwcode_categories}
  • Is this a feature request? If so, you need to email the developer directly. – Anna_MediaGirl Feb 22 '13 at 5:31
  • 1
    i don't think gw-categories looks at selected categories for an entry. What are you trying to do? What flexibility do you need that SC doesn't give you? – GDmac Feb 22 '13 at 8:04
  • with GWCode Categories I will be able to user the parent_id and the children_id to help filter the categories better on user select, but i tried {checked} and it doesnt work – Kevin Feb 22 '13 at 16:41
1

When within a SC form, GWcode Categories will not be aware of which categories are currently selected for the entry. You'll have to use Safecracker's {categories} loop.

| improve this answer | |
  • Is there a way to make it work with gwcode categories? I notice safecracker doesnt have a way to get the children_id, like gwcode categories does – Kevin Feb 22 '13 at 16:46
  • Not to my knowledge, no. – Derek Hogue Feb 22 '13 at 17:19
  • darn, thanks for responding you cant even do a simple if else conditional in the categories tag – Kevin Feb 22 '13 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.