Announcement

Collapse
No announcement yet.

Assign an image file to a variable?

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

  • cpp-dev
    replied
    Still muddling though.

    I thought maybe something with 'mvt:do' like: (based on Miva Docs: Image_Load_File)
    Code:
    <mvt:do file="g.Module_Library_DB" name="l.settings:navigationitem:category:cattree:image" value="Image_Load_File('graphics/00000001/logo-bravecto-main.png')" />
    then I try to call the entity and I don't see anything:
    Code:
    <div>
      <mvt:item name="content" />
      <div class="row">
        &mvte:local:settings:navigationitem:category:c attree:image;
      </div>
    </div>
    It seems like this is most likely candidate for working but it still feels out of reach.

    Leave a comment:


  • habreu
    replied
    I'm not sure if this is useful but Tool Belt is available for free on the Miva app store https://apps.miva.com/miva-toolbelt.html

    It has a function which if I understood correctly may do what you want

    Category_Images

    This item loads the Category Title and Category Tree images into a user selected variable name.

    Code:
    <mvt:item name="ry_toolbelt" param="category_images|g.imgsrc|g.category_code" /> <mvt:item name="ry_toolbelt" param="category_images|g.imgsrc|l.all_settings:sub cat:code" />  
    
    Example 1: Category Title image
    
    <mvt:if expr="NOT ISNULL g.imgsrc:title">  <img src="&mvt:global:imgsrc:title;"> </mvt:if>  
    
    Example 2: Category Tree image
    
    <mvt:if expr="NOT ISNULL g.imgsrc:tree">  <img src="&mvt:global:imgsrc:tree;"> </mvt:if>

    Leave a comment:


  • cpp-dev
    replied
    Thanks for the tip Kent Multer . It didn't fix the issue, but it was a good reminder to check for some of those small mistakes.

    I'm not seeing anything else odd at the moment, well other than the missing image.

    Leave a comment:


  • Kent Multer
    replied
    Hmmm, I don't have time to decode all this today, but I did notice an error in that first mvt:assign element. To assign a string value, you need to enclose it in single quotes, inside the double quotes, e.g.:
    Code:
    <mvt:assign name="l.settings:navigationitem:category:cattree:image" value="'graphics/00000001/logo-product-main.png'" />
    Note the doulbe and single quotes before "graphics," and the single and double quotes after "png."

    Your sample also had a space in the word "image," but I think that's probably a forum bug; it happens a lot when people paste code into their posts.

    I don't claim that that will fix everything, but it's a good place to start.

    HTH --

    Leave a comment:


  • cpp-dev
    started a topic Assign an image file to a variable?

    Assign an image file to a variable?

    I have a navigation set, that has default calls for things found on a Category listing. But a "plain" category wasn't working as we want to display several categories on the page, not just the products. This page is meant to show the groupings that are under a single brand, but not just splat all the products on the page.

    The page is fine, and with a little guidance from Tech Support I modified the nav set template/iterator to render the page link in the navigation set.

    But we also want to have an image with said link as to have it look like the other category listings.

    I assume it possible to assign an image file to a variable. I have tried this, and it lives in the template of the page, but it doesn't seem to show the image.

    Code:
    <mvt:assign name="l.settings:navigationitem:category:cattree:i mage" value="graphics/00000001/logo-product-main.png" />
    And for this is the nav item template

    Code:
    <section>
    <!--<h2>Featured Categories</h2>--> <div class="featured-categories">
    <mvt:if expr="NOT ISNULL l.settings:readytheme:navigationitems"> <ul class="featured-categories__list no-list row">
    <mvt:foreach iterator="navigationitem" array="readytheme:navigationitems">
    <mvt:comment><mvt:if expr="l.settings:navigationitem:link_type NE 'C'"> <mvt:foreachcontinue /> </mvt:if></mvt:comment>
    <mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_Code( l.settings:navigationitem:link_dest, l.settings:navigationitem:category )" /> <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.settings:navigationitem:category:cattree_r esult" value="CSSUI_CatTree_Load( l.settings:navigationitem:category:id, l.settings:navigationitem:category:cattree )" /> <mvt:assign name="l.settings:navigationitem:link_href" value="gettoken( gettoken( l.settings:navigationitem:link, '\"', 2 ), '\"', 1 )" /> <mvt:assign name="l.settings:navigationitem:link" value="glosub( l.settings:navigationitem:link, ' href=', ' class=\"featured-categories__name\" href=' )" />
    <li class="featured-categories__item column half medium-one-fifth align-center">
    <mvt:if expr="l.settings:navigationitem:category:cattree:i mage">
    <a href="&mvt:navigationitem:link_href;" class="featured-categories__image-link vertical-align-parent">
    <img src="&mvt:navigationitem:category:cattree:image;" alt="&mvt:navigationitem:category:name;" class="featured-categories__image vertical-align">
    </a>
    </mvt:if>
    &mvt:navigationitem:link;
    </li>
    </mvt:foreach> </ul> </mvt:if>
    </div>
    </section>
    Last edited by cpp-dev; 02-04-21, 10:33 AM. Reason: Clarify formatting in code blocks
Working...
X