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.

selectable image as option

Discussion in 'Showcase Support' started by kisanjong, Dec 15, 2014.

  1. kisanjong

    kisanjong New Member AMS Showcase

    Hi bob

    Is it possible to add a feature where when you select an option on the data entry it will show a image.

    For example let say I select Ford it will show the Ford logo in the final description.

    The image needs to be pre added via the Admin panel and have their own category, logos etc which are then linked to that percific option.

    Create option - option name - linked images - logos.

    I hope you understand what I'm trying to say :)

    Thanks
     
  2. Bob

    Bob Developer Staff Member

    Im pretty sure that is doable via custom fields (at least I've seen some people do similar things via custom fields). Also, each Category has an optional Category Image field that can be used for customization purposes. A lot of people use the Category Images to create a Image Based category navigation system.
     
  3. kisanjong

    kisanjong New Member AMS Showcase

    Thanks Bob

    More details of the option

    Final description would look like this

    Main image..

    Name: Mustang
    Make: Ford
    logo: Ford logo here
    Image2: here would be another image simular to logo that was added to a different image category to logos
    specs:
    Spec2:
    Spec3:
    Etc

    And a random question are the templates used editable to suit different needs and layouts

    Btw none of my site is related to cars, I'm just using cars as an example.

    Thanks again
     
  4. Bob

    Bob Developer Staff Member

    Yes, you can do that with custom fields by using the Self Placement field location and editing the template placing the field where you want it to display.

    You can modify the templates and CSS to your needs.
     
  5. kisanjong

    kisanjong New Member AMS Showcase

    Sorry for the very.. Delayed reply as I've just come back to this :)

    Ok so I want to use the self placement but add an image in place of the text.

    For the code this works great for the text but how can I replace the value with a corresponding image (self placement only and not the standard template area)

    Code:
    {xen:helper showcaseFieldValue, $item, 'car_colour', {$item.customFields.car_colour}}
    Let say the field value is colour_red it will show a red Swatch instead of the word Red or the Audi logo instead of the word Audi etc.

    Can you give me a clue.

    Thanks
     
    Last edited: Jul 14, 2017
  6. Bob

    Bob Developer Staff Member

    You could use the Value Display HTML option for the custom field.

    Edit the Custom Field and click on the General Options tab. At the bottom of that tab you will see an option named "Value Display HTML". This lets you do things like display an IMAGE based on the value of the Custom Field.

    Selection_773.png

    HTML:
    <img src="http://www.YOURSITE.com/path-to-image-directory/{$valueRaw}.png" />
     
    kisanjong likes this.
  7. kisanjong

    kisanjong New Member AMS Showcase

    Brilliant thanks bob, the showcase add-on just gets better and better ;)
     
  8. Bob

    Bob Developer Staff Member

    There is {$value} and {$valueSC} that you can use as well (in case {$valueRaw} doesn't work for your situation). Its a pretty neat feature and you can do a lot with it.

    Also {$choice} might even be a better option to use if its a "select" type field.
     
    kisanjong likes this.
  9. kisanjong

    kisanjong New Member AMS Showcase

    Thank you :)

    What's the difference between value and valuesc?
     
  10. Bob

    Bob Developer Staff Member

    For Radio, Select, Checkbox and Multi Select fields, {$value}, {$valueRaw} and {$valueSC} are actually the same. Its the "text input" type fields that are different.

    For bbcode (Rich Text Editor) fields
    PHP:
                    $valueRaw htmlspecialchars(XenForo_Helper_String::censorString($value));
                    
    $valueSC nl2br(htmlspecialchars(XenForo_Helper_String::censorString($value)));  // This is how User Fields are parsed
                                
                    
    $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $view)));
                    
    $value $bbCodeParser->render($value, array(
                        
    'noFollowDefault' => empty($item['isTrusted'])
                    ));
    For textbox and textarea fields
    PHP:
                    $valueRaw htmlspecialchars(XenForo_Helper_String::censorString($value));
                    
    $valueSC nl2br(htmlspecialchars(XenForo_Helper_String::censorString($value)));
                    
    $value XenForo_Template_Helper_Core::callHelper('bodytext', array($value));  
     
  11. Bob

    Bob Developer Staff Member

    I think {$choice} is going to be the best way. if {$choice} = Red, then you'd name the image Red.png (all the extensions would need to be the same).
     
    kisanjong likes this.
  12. Bob

    Bob Developer Staff Member

    There are a few others available as well.

    {$itemId}, {$itemName}, {$categoryId}

    If you wanted to, you could do something like this..

    HTML:
    <img src="http://www.YOURSITE.com/path-to-image-directory/{$choice}-{$categoryId}.png" />
    where Choice = Red and Category Id = 10 (Ford) which would convert to Red-10.png (which would be an image of a Red Ford).

    where Choice = Red and Category Id = 20 (Chevy) which would convert to Red-20.png (which would be an image of a Red Chevy).
     
  13. kisanjong

    kisanjong New Member AMS Showcase

    Very clever, it's all coming together now thanks again :)

    Off to test this.
     
  14. kisanjong

    kisanjong New Member AMS Showcase

    This is the one :) working perfect thanks bob
     
    Bob likes this.
  15. Bob

    Bob Developer Staff Member

    Awesome! Have a great weekend :)
     
  16. kisanjong

    kisanjong New Member AMS Showcase

    Bob just wanted to say thanks again this is coming together nicely now :)

    I've also managed to make the image linkable etc..

    Based on the wonderful :) advanced field search, Do we have a advanced field search string /URL?

    domain.com/showcase/search?q=make+audi

    That will list all Audi

    Or

    domain.com/showcase/search?q=colour+red

    That will list all red etc etc.

    Thanks
     
  17. Bob

    Bob Developer Staff Member

    Showcase doesn't have that (it takes some major modification to the entire field search system), however, a new addon of mine does have that functionality and at some point I will most likely be modifying showcase's field search as well.
     
  18. kisanjong

    kisanjong New Member AMS Showcase

    No problems :) Certainly looking forward to this feature.

    Are we talking a major release of showcase V3/xenforo 2 etc? Or showcase 2.x
     
  19. Bob

    Bob Developer Staff Member

    It requires architecture changes and I only do that level of change in a 1st point release, so SC 3.0
     
  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.