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.

Custom Fields

Discussion in 'Showcase Support' started by ibenick, Dec 8, 2012.

  1. ibenick

    ibenick Member Showcase

    I need to setup some custom fields that will be populated when creating a Showcase item. I played with Waindigo's custom fields add-on but I can't figure out how to get it to play with Showcase, so I was thinking I could just do this with template edits as it is information that will be necessary for all of my showcase items.

    If I understand correctly, this will involve editing the item template and the create item template.

    In the sidebar of the item template, I added some lines to the quick stats that I would like to populate information, like this:

    Code:
                    <dl>
                        <dt>Longest Rappel:</dt>
                        <dd>{$longest_rap}</dd>
                    </dl>
                     <dl>
                        <dt>Time Commitment:</dt>
                        <dd>{$time_commit}</dd>
                    </dl>
    I would then like to create fields in the item create template so that they fill out the item name, then things like Longest Rappel, Time Commitment, etc.

    So I duplicated the field for item name and modified it for the other fields, the problem I'm having is getting that data to actually populate in the created item. This is what I added in the create item template:

    Code:
    <dl class="ctrlUnit">
    <dt><label>Longest Rappel:</label></dt>
    <dd><input type="text" name="longest_rap" class="textCtrl" maxlength="50" /></dd>
    </dl>
     
    <dl class="ctrlUnit">
    <dt><label>Time Commitment:</label></dt>
    <dd><input type="text" name="time_commit" class="textCtrl" maxlength="50" /></dd>
    </dl>
    
    I feel like there must be some relatively simple way to now connect these two elements, but I'm missing it. Can you point me in the right direction?

    Thank you so much!

    Side note: I am loving Showcase and will be buying another license once I get this one all ironed out. Do you sell branding removal as well?
     
  2. Bob

    Bob Developer Staff Member

    This is much more extensive than making a few template edits. This involves code modifications to methods in the controller(s), model(s) and datawriter(s) as well as add fields to the items table to store the data.

    Basically (very brief not so technical explanation), what you'd need to do next is edit the controller that contains the method that the form action is pointing to. You'd need to grab the new fields being passed in for processing. Processing in this case involves adding the data to the database via the datawriter. The Datawriter won't know what to do with it until you tell it that it is part of the items table (which you will need to edit and add fields to it). You will need to modify the complete functionality of both ADD and EDIT (as they have methods in different controllers). Then there is display.... you need to modify the controller for where you want to expose the data for display. In order for data to be exposed, you must "call" it. so you will have to either create methods in the controller and model to retrieve the data or modify existing queries to include it. If you are up for Learning, this is a perfect opportunity. If you are a novice coder, you should have no problem reverse engineering it as you can follow along with the item title as an example.

    It would honestly take me less time to knock something like this out as custom work as it would for me to explain how to do something like this step by step.
     
  3. tajhay

    tajhay Active Member AMS Premium SC Premium Sportsbook Pickem Power Rankings Survivor

    Any update on when we can get a tutorial on custom fields?

    Also, i plan on using showcase as a sports team player profiles. I plan on having a custom table with generated stats. Is there a way for showcase to display this information? i.e. read another table and display it in one of the tabs? :)
     
  4. ibenick

    ibenick Member Showcase

    I can put together the tutorial within the next week. Been pretty busy and haven't been able to get to it.
     
    tajhay likes this.
  5. Bob

    Bob Developer Staff Member

    Of course. I follow all the standard xenforo architecture, so all you'd have to do is "extend" various aspects of the addon with your own addon. The best way (IMO) is to extend the indexItem Controller and add your stats data into the viewParams and then edit the Item Template to add a new tab with an include to a custom template that will display the stats data based on what you injected.
     
    tajhay likes this.
  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.