Announcement

Collapse
No announcement yet.

Quicklist - Add a comma after each list item on display

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dcarver
    replied
    You'd could probably use an mvt:capture to and then only use mvt:evals inside of the capture? Otherwise you'd probably need to use <mvt:miva output="off" /> and then do <mvt:eval /> all the other data. <mvt:capture> may also work.

    Leave a comment:


  • eldon99
    replied
    dcarver, thank you for that code. The one thing is that I cannot figure out how to avoid a space before the comma.

    Leave a comment:


  • alphabet
    replied
    Got it.

    Thank you for the explanation and your code evaluates faster.

    Leave a comment:


  • dcarver
    replied
    alphabet my code does avoid the comma at the end. We are outputting the comma BEFORE we output any data for the loop. So if we are on the last element, and the last element position isn't one, we output a comma so it goes <element>,<last_element> where the comma and <last_element> all occur in the last iteration of the loop.

    Leave a comment:


  • alphabet
    replied
    dcarver I just want to make sure I understand l.pos, wouldn't he want to avoid the comma at the end?

    Code:
     
     <mvt:foreach ...>  All your other code here...  <mvt:if expr="l.pos1 NE miva_array_elements(array)" >,</mvt:if> </mvt:foreach>
    (Good for building JSON)

    Also, if you have nested loops, the inner loop becomes l.pos2 etc.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Not sure of the particular here since i never used toolkit much, but, doesn't toolkit accept global variables? If so, just use the Product_Read() custom field function to create a global that can be read by toolkit.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Scot - ScotsScripts.com View Post
    Yes :) I'm just not clear what your starting condition is. If the codes are already in the custom field then it would be easy to turn them into an array and use a foreach to roll through them.
    I'm currently using the Toolkit snippet to create a Quicklist. You have to go to the code in the template every time you want to update the products being displayed. I wanted to create a custom field that I could enter the product codes into it, then place that custom code into the Toolkit snippet which would, in turn, load the products to be displayed. I'm thinking that I cannot have something like &mvt:customfield_values:customfields:madness; within the Toolkit snippet.

    I'm tagging along on this thread to see if there is a much better way to do this that would allow me to use custom fields and mivascript instead of the Toolkit.

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    Yes :) I'm just not clear what your starting condition is. If the codes are already in the custom field then it would be easy to turn them into an array and use a foreach to roll through them.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Scot - ScotsScripts.com View Post
    Are you saying you have a custom field already populated with comma separated product codes, or are you trying to dynamically load product codes into a custom field on the page using template scripting?
    Me?

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    Are you saying you have a custom field already populated with comma separated product codes, or are you trying to dynamically load product codes into a custom field on the page using template scripting?

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by eldon99 View Post
    I am building a quicklist on the product page with a comma separate list of related product codes. I need to be able to separate each list item with a comma on the page (as opposed to line breaks). I looked at the pos1 docs, but if my theory is correct, I will end up having a comma after the last item. How can I avoid that?
    I was just working with the Toolkit Quicklist and was wondering if anyone had (or is) done (doing) something to replace it. In my concept, I'd like to be able to load the "quicklist" products into a custom field (so that the code on the page won't have to be tweaked each time an update is needed). I had been playing around with trying to use a custom product field in this

    Code:
    <mvt:item name="toolkit" param="quick|pcount|&mvt:customfield_values:customfields:madness;" />
    It may not have work because of the formatting I tried using.

    Anywho, I'm tagging along to see if I can glean some insight.

    Leave a comment:


  • dcarver
    replied
    Code:
    <mvt:foreach ...>
    <mvt:if expr="l.pos1 GT 1">
        ,
    </mvt:if>
    
    All your other code here...
    </mvt:foreach>

    Leave a comment:


  • Quicklist - Add a comma after each list item on display

    I am building a quicklist on the product page with a comma separate list of related product codes. I need to be able to separate each list item with a comma on the page (as opposed to line breaks). I looked at the pos1 docs, but if my theory is correct, I will end up having a comma after the last item. How can I avoid that?
Working...
X