• Resolved Greg_R

    (@greg_r)


    Is there a way for MLA to find the url of an attachment’s parent? In other words, if I have a Woocommerce product and add an image to it, can we set up a template or custom field that will get the product’s permalink? Then, when we create a gallery, we can choose to link the thumbnails to the parent product if it exists, or link directly to the image file by default.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Greg_R

    (@greg_r)

    Here’s my progress so far. I have a conditional/choice statement using a custom field where I manually enter the product url, if the product exists. Otherwise it defaults to a file link which results in a lightbox because of the simple lightbox plugin I have installed. It would be great though if I could grab the product link dynamically, and the only way I can think of to get that to happen is to have the image file be attached to the product. How can I build a link to the attachment parent?

    [mla_gallery attachment_category="{+template:{+request:current_item+}|grill-accessories+}" mla_output="paginate_links,prev_next" posts_per_page="36" columns=4]
    
    [mla_term_list parent=82 option_all_value='grill-accessories' option_all_text='--Grill Accessories--' mla_markup=dynamic-dropdown]
    
    [mla_gallery attachment_category="{+template:{+request:current_item+}|grill-accessories+}" posts_per_page="36" link=file mla_link_href="{+template:({+custom:produrl+}|{+filelink_url+})+}"  mla_rollover_text="{+title+}" columns=4 size=full]
    Plugin Author David Lingren

    (@dglingren)

    Thanks for your question and for the update with your progress so far. If I understand your question correctly, you can find an answer in this earlier topic:

    What are the default values for the markup template?

    That topic tells you how to install the “MLA Substitution Parameter Hooks Example” plugin and use its [+parent:permalink+] value. Does that get you what you need?

    You can also have a look at the “WooCommerce Fixit” example plugin, which uses the same substitution parameter hooks to implement a “product:” prefix that includes [+product:permalink+].

    Let me know if the above suggestions are useful.

    Thread Starter Greg_R

    (@greg_r)

    Thanks David! I’ve been busy on another part of the project but now I can return to my refinement of this shortcode, so it looks like the WooCommerce Fixit will be perfect. I’ll report back ASAP.

    Thread Starter Greg_R

    (@greg_r)

    After installing WooCommerce Fixit, the product:permalink hook works perfectly, thanks so much! So even though I initially thought that the attachment parent would be the solution to my challenge, linking to the WooCommerce product for which the image is being used is the direct solution.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the good news. I’m happy to hear that the product:permalink custom data source solved your application needs.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding example plugins or WooCommerce tools.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can we get the url of an attachment parent?’ is closed to new replies.