Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to 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.

On Showcase Creation - Write All Showcase Field Data in First Post of Threa


Active Member
AMS Premium
CAS Premium
RMS Premium
SC Premium
UBS Premium
We have it set up so that a new thread is created for each showcase. The problem is this - before we had showcase, we had members starting Build Threads in the forum with tons of information about their builds... goals, mod lists, etc. They have even gone back to edit their initial post with updates (imagine keeping an index of a journal) pointing to specific posts within the thread where their updates can be found. Here's an example:

Now that we have showcase auto-creating threads, here's what the initial post in the thread looks like:

Big difference, right? I'm afraid that these initial posts are hurting the engagement of that forum.

What I'd like to do is find a way to dump all of the text field data from the showcase into that initial post so that it looks more interesting and engaging, and encourages people to reply and engage in discussion - still keep the link down at the bottom of the post pointing users to view the showcase item. I think this would be a good compliment to the upcoming implementation of the Create Showcase button that's being worked in, as it would be another way to create a tighter integration between the showcase items and the forum they're tied to.
You can easily modify the showcase thread model to do what you want. I do it with Sportsbook to display all the outcomes and odds.


You'd need to modify the create thread method slightly (mainly the fetching and preparing of the item itself so you can use custom fields).

Then you'd need to modify the below method that prepares the first post message (since it needs to be stored as a POST).

    * Prepares the message for the first post of a new showcase discussion thread
    * @param array $item
    * @return string
    public function prepareMessageForFirstPost(array $item)
        $snip = XenForo_Application::get('options')->scMaxMessageSnippetLength;
        $snippet = trim(XenForo_Helper_String::wholeWordTrim($item['message'], $snip));
        $message = new XenForo_Phrase('nflj_showcase_message_create_item', array(
            'title' => $item['item_name'],
            'username' => $item['username'],
            'userId' => $item['user_id'],
            'snippet' => $snippet,
            'itemLink' => XenForo_Link::buildPublicLink('canonical:showcase', $item)
        ), false);
        return $message;      

Here is an example of how I do it for sportsbook..
     * Prepares the message for the first post of a sportsbook discussion thread
     * @param array $event
     * @return string
    public function prepareMessageForFirstPost(array $event)
        $snippet = "Outcomes w/Current Odds \n\n";
        $outcomes = $this->_getSBOutcomeModel()->getOutcomes(array('event_id' => $event['event_id']));
        $outcomes = $this->_getSBOutcomeModel()->prepareOutcomes($outcomes);
        foreach ($outcomes as $outcome)
            $snippet .= $outcome['outcome_title'] . " : "
                . $outcome['outcome_current_odds_against'] . "/" . $outcome['outcome_current_odds_for']
                . " (" . $outcome['outcome_current_odds_decimal'] . ")\n\n";
        $message = new XenForo_Phrase('nflj_sportsbook_message_create_event', array(
            'title' => $event['title'],
            'username' => $event['username'],
            'userId' => $event['user_id'],
            'snippet' => $snippet,
            'eventLink' => XenForo_Link::buildPublicLink('canonical:sportsbook', $event)
        ), false);   

        return $message;

here is what it looks like (and you don't HAVE to put it in the quote snippet either, I've just followed core xf/rm standardization)
Damn, wish I could look at the db structure and Model of Sportsbook to compare. I'm thinking the outcomes is going to be handled differently than custom field data. Still trying to wrap my head around gathering/preparing/displaying custom field data, mainly because of the way it's stored in the db.
Its really not that different than how you are doing it for the LISTING pages. You don't have to GATHER custom fields data as its CACHED in each item. The thing with this is, I am only fetching the bare item as its not being used for anything other than a snippet of the message body from tab 1, so as I mentioned above, you will need to fetch the full item (which joins the Category and User data) and then run it through the prepare item method (which part of that prepares the custom fields for display). You can then grab the custom fields in the same way you do on the item template or category template for display, cept you will need to "build" the phrase similar to how I dynamically build it for sportsbook.

Hope that made more sense?
Alright Bob, I've been looking at a lot of code and I hope I'm getting closer to working through this one...

For modifying the createThread function in the Thread model -

1. It looks like the function is already fetching the item using this line:
$item = $scItemModel->getItemById($itemId);
You mentioned that it would have to be changed to fetch the full item. Would that mean changing the function being called from getItemById to prepareItemFetchOptions?

2. As for the next step in preparing items, can I just add a line below the one above calling the prepareItem function, like this:
$item = $scItemModel->prepareItems($items, true);
That function looks like the one that calls all the user and category data, and custom field data. Is that all that would need to be done in the createThread function? It seems a little odd to use the same variable twice in two lines to call two different functions but I've seen it done in the studying I've been doing.

If I'm way off, just say so. I'll do some more reading.
close, but not quite.

for #1, you use the getItemById method, however, you need to pass in some fetchoptions (specially to fetch the user record and full category record joined).

for #2, you need to prepare the item via the prepareItem method. The prepareItems method is for preparing BULK items (like for listings).

You also need to prepare custom fields.

To get a better understanding, just look at the NFLJ_Showcase_ControllerHelper_Showcase::assertItemValidAndViewable method
:) didn't expect to get it right so soon. I'll do some reading in that file and see what I can come up with next.
It won't be done EXACTLY like the Helper tho, but you can see get an idea of what I am talking about as the helper is doing the things I am talking about.