We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    Quote from: Bruno17 at Jul 07, 2013, 10:09 AM
    I'm thinking it's something along the lines of opening the TV for MIGx, and then adding another form field, and grid column. Then, applying it to my .tpl that contains the <li></li>

    exactly that.

    Thanks Bruno:

    So I'm thinking add a field called "image-link-path"
        {"field":"image-link-path","caption":"Image-Link-Path"},

    Put a column in the grid for it. Probably doesn't need to be sortable.
    {"header": "Image Link Path", "sortable": "false", "dataIndex": "image-link-path"},


    Then for my tpl
    <li>
      <a href="[[+image-link-path]]"><img src="[[+image]]" alt="[[+description:htmlentities]]" /></a>
    </li>


    Haven't implemented and tested yet. Already have questions. I'm guessing the site admin would enter [[~id]] — id being the id number for the resource to link to.

    This structure would put an href on all list items. What if only one of the images actually needs to hyperlink to another resource?
    Hmmm?
      • 19872
      • 1,078 Posts
      Still attempting to solve this issue of attaching a hyperlink to an image in the gallery. Am I overthinking this?

      Going a step farther, if I use
      [[~[[+image-link-path]]]]
      instead of
      [[+image-link-path]]"
      then whoever is inserting images and links into the form should only have to type the number of the resource id.

      Still stuck though. What if the user does not put in a resource number. With my current tpl some of the html markup will still appear. Doesn't seem proper to have all the href code and closing a tag if there is no actual path inserted.

      Do I need two tpls for the li? One for an image with a hyperlink and one for without. How would I get MIGx to pick between the two. Some kind of a conditional bit of code?

      I have scoured the internet and forum looking for examples. Amazingly, I find plenty of info and tutorials on getting an image on a page with MIGx and getImageList, but none that show of discuss putting a hyperlink on each image.
        • 4172
        • 5,888 Posts
        you can either use the if - snippet or a conditional-output-filter like:

        [[+image-link-path:is=``:then=`
        <li>
          <img src="[[+image]]" alt="[[+description:htmlentities]]" />
        </li>
        `:else=`
        <li>
          <a href="[[~[[+image-link-path]]]]"><img src="[[+image]]" alt="[[+description:htmlentities]]" /></a>
        </li>
        `]]


        or better add a template-switcher-field to your formtabs for example

        name: tpl
        inputTVtype: listbox
        input-option-values:
        imageonly||imagewithlink


        and create two different chunks with this names.

        and this property to your getImageList-call:

        &tpl=`@FIELD:tpl`







          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 19872
          • 1,078 Posts
          Quote from: Bruno17 at Jul 08, 2013, 12:23 AM
          you can either use the if - snippet or a conditional-output-filter like:

          [[+image-link-path:is=``:then=`
          <li>
            <img src="[[+image]]" alt="[[+description:htmlentities]]">
          </li>
          `:else=`
          <li>
            <a href="[[~[[+image-link-path]]]]"><img src="[[+image]]" alt="[[+description:htmlentities]]"></a>
          </li>
          `]]


          or better add a template-switcher-field to your formtabs for example

          name: tpl
          inputTVtype: listbox
          input-option-values:
          imageonly||imagewithlink


          and create two different chunks with this names.

          and this property to your getImageList-call:

          &tpl=`@FIELD:tpl`








          Thanks Bruno: I'll give this a try today.