• REGISTRATION REQUIREMENTS:

    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.

Quick Default Option Query

DeviateDefiant

Member
SC Premium
Is there a simple way for me to by default have all new items featured? I know it's against the premise behind the "feature" feature, but I use it with the XenPorta block on the homepage which randomly displays a selection of featured vehicles.
 
Hi,
what is with the block "ShowcaseImages"
Data Type "Most Recent" an "Images to display"
With it you see always the newest items, or what do you want?
 
I display a random selection from all the items in the showcase using the featured option, as Bob doesn't want to add a feature that does this natively because of the potential performance hit from doing so.

I have no issue with the load so made a pseudo-random by using the block with 'featured cars' from which it selects randomly anyway. The only pitfall in doing so is that each new addition needs to be manually featured.
 
I'd just create a CRON that will run a update statement daily. If you need me to, I can add code to the model that will allow you to pull items randomly, then you can modify the xenporta block (php file) to fetch random items.
 
Thanks @Bob, I'd much rather go that route, I'd rather a native "random" implementation than my hacky solution. I have everything cached for a minute anyway so the load effect shouldn't be a concern. If you can get me started, I'm sure I can figure out the rest :)
 
Edit the item model: /library/NFLJ/Showcase/Model/Item.php

find the prepareItemOrderOptions method and add a new choice to the end of the choices array as shown below.
PHP:
    /**
     * Construct 'ORDER BY' clause
     *
     * @param array $fetchOptions (uses 'order' key)
     * @param string $defaultOrderSql Default order SQL
     *
     * @return string
     */
    public function prepareItemOrderOptions(array &$fetchOptions, $defaultOrderSql = '')
    {
        $choices = array(
            'recent' => 'item.date_added',
            'rated' => 'item.rating_avg %s, item.rating_count DESC, item.likes DESC, item.view_count DESC',
            'reviewed' => 'item.review_count %s, item.rating_avg DESC, item.likes DESC, item.view_count DESC',
            'popular' => 'item.view_count %s, item.rating_avg DESC',
            'liked' => 'item.likes %s, item.rating_avg DESC, item.view_count DESC',          
            'updated' => 'item.last_update',              
            'featured' => 'rand() %s, item.last_update DESC',
            'atoz' => 'item.item_name',
            'random' => 'rand()',
        );
        return $this->getOrderByClause($choices, $fetchOptions, $defaultOrderSql);
    }


The edit the XenPortaPotty Block file: /library/EWRporta/Block/ShowcaseFeaturedItems.php

Find this:
PHP:
        $conditions = array(
            'category_id' => $catIds,
            'image' => ($imageRequired == 1) ? true : false,
            'featured' => true  
        );

Set featured to: false


Find this:
PHP:
        if ($featuredItems = $scItemModel->getItems($conditions, array(
            'join' => NFLJ_Showcase_Model_Item::FETCH_CATEGORY
                | NFLJ_Showcase_Model_Item::FETCH_USER,
            'limit' => $options['scFI_numItems'],
            'order' => 'featured',
            'direction' => 'DESC')))
        {

set order to: 'random'
 
Thank you mate. Done, I then updated all the items not to be featured any more:
Code:
UPDATE `xf_nflj_showcase_item`
SET featured=0
But I'm not getting any of them show, tinkering still now to find a solution.
 
Two thoughts, either there's an additional "featured" check somewhere, or the scripts I've been modifying are cached somewhere?

All XenPorta blocks have built in cache by default. For testing, you need to disable the block cache (uncheck the "Enable caching of data every" option.

Selection_434.png
 
Oopsie, well that explains it, I was talking about the "Showcase Images" block set to "Featured" and not the "Showcase Featured" block, just trying to replicate the modifications in that file now.
 
Just set featured option to false : false and still check "featured" in the options
PHP:
'featured' => ($options['scI_sortOrder'] == 'featured') ? false : false,

Also still need to change the ORDER
change this:
PHP:
            'order' => $options['scI_sortOrder'],

to this:
PHP:
            'order' =>'random',
 
Back
Top