1. REGISTRATION REQUIREMENTS:

    Register with your xenforo.com Username then start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Allow 1 item per user

Discussion in 'Showcase Support' started by bloh, Jul 8, 2014.

  1. bloh

    bloh New Member Showcase

    I wanted to add a line of conditional statement.
    "If current visitor showcase item count > 0", then hide the 'create showcase item' button.
    is it possible? If so, what's the conditional code? Thanks in advanced :)
     
  2. Bob

    Bob Developer Staff Member

    You'll need to edit all the templates that have the create button (there are a lot of them) and wrap it with this.

    HTML:
    <xen:if is="{$visitor.showcase_count} == 0"> CREATE BUTTON CODE </xen:if>
    Create button code looks something like this (they are not all exactly the same)...

    HTML:
    <xen:if is="{$canCreateItem}">
        <xen:topctrl><a href="{xen:link showcase/add}" class="callToAction OverlayTrigger"><span>{xen:phrase nflj_showcase_create_new_item}</span></a></xen:topctrl>
    </xen:if>
    NOTE: you MUST do it INSIDE of the cat create item if statement, like this..

    HTML:
    <xen:if is="{$canCreateItem}">
        <xen:if is="{$visitor.showcase_count} == 0">
            <xen:topctrl><a href="{xen:link showcase/add}" class="callToAction OverlayTrigger"><span>{xen:phrase nflj_showcase_create_new_item}</span></a></xen:topctrl>
        </xen:if>
    </xen:if>
    >
     
    Last edited: Jul 8, 2014
    bloh likes this.
  3. bloh

    bloh New Member Showcase

    Thanks lot! will try.
     
  4. Bob

    Bob Developer Staff Member

    Instead of > 0 its best to use == 0 and only display it if they have not yet created an item (if they have permission).

    Might not be a bad idea to add item amount limitations to user group/category permissions
     
    bloh likes this.
  5. bloh

    bloh New Member Showcase

    This doesn't include moderated item.
    {$visitor.showcase_count} == 0

    What is the variable for moderated item?

    Thanks.
     
  6. Bob

    Bob Developer Staff Member

    There is none. The field 'showcase_count' is a cached visible item count added for display purposes outside of showcase only (similar to resource_count, message_count, etc). I don't know of any addon (and core XF for that matter) that adds any "moderated" counts of any type to the xf_user table for use within the $visitor object.

    Im pretty sure item create limits has been requested (not in my office right now, So I can't look on the white board). That is what you are wanting right?
     
  7. bloh

    bloh New Member Showcase

    Yup.
    That's fine. I'll take another route.
     
  8. Bob

    Bob Developer Staff Member

    Keep in mind, there are 4 item_states... 'visible', 'moderated', 'deleted', 'draft', so if you are doing any querying to generate a COUNT(*), you might want to filter out deleted so that it doesn't count that in case that user has had a previous item soft deleted.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.