album name begins with (like)
-
Hi David. Many thanks for this great plugin. I might have discovered it a little late, but i am using it now in all installation i a supervise. Reading most threads in the support forum, truly admire how kind and helpful you are.
The flexibility and multitude of features of this plugin gets me lost sometime, so i am here for help.
— How do i display a simple MLA gallery of type=images of certain att_category using (image name and/or att_tag) that begins with a certain string?
— I have seen and tried your way to link album to single using a page. Is there a way to link an album to a larger album page?
(i plan to use a shortcode to pull only 3 images in some pages, and would like the user upon clicking any of them to go to a page where more images of same criteria are displayed).Many thanks.
-
This topic was modified 8 years, 3 months ago by
Abdullah Ali.
-
This topic was modified 8 years, 3 months ago by
-
Thanks for the positive comments on the plugin and its support, and thanks for your questions.
Regarding your first question about combining a category and search string in a single query, here is one possible solution that has a simple form, a pagination controls gallery and an image gallery:
<form id="mla-text-form" action="." method="post" class="row"> <strong>Att. Categories Dropdown</strong> [mla_term_list taxonomy=attachment_category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false] <p> Search: <input id="mla-search-box" name="mla-search-string" type="text" placeholder="Name/Tag Search" /> </p> <input id="text-form-submit" name="text_form_submit" type="submit" value="Search" /> </form> <h3>Gallery</h3> [mla_gallery] s="{+request:mla-search-string+}" mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag attachment_category="{+template:({+request:tax_input.attachment_category+}|no-term-selected)+}" posts_per_page=3 mla_output="paginate_links,prev_next" mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[attachment_category]="{+query:attachment_category,text+}"' [/mla_gallery] [mla_gallery] s="{+request:mla-search-string+}" mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag attachment_category="{+template:({+request:tax_input.attachment_category+}|no-term-selected)+}" posts_per_page=3 mla_caption="{+title+} : {+description+}" mla_nolink_text="<br>Select a term to display the gallery.<br>" [/mla_gallery]
The selection parameters must be the same for both
[mla_gallery]
shortcodes. They are:s="{+request:mla-search-string+}"
provides a keyword search using the value entered in the text box. If the box is empty no keyword filter is used.mla_search_fields="title,terms"
searches the image name field and the taxonomy terms.mla_terms_taxonomies=attachment_tag
limits the terms search to the Att. Tags taxonomy.attachment_category="{+template:({+request:tax_input.attachment_category+}|no-term-selected)+}"
takes the term selected in the dropdown control. If no selection has been made (such as when the page is first displayed) an invalid term suppresses the gallery display.posts_per_page=3
limits each page of the display to three or fewer items.
There are many ways to implement the input form, but this should get you started.
Regarding your second “link to a larger album” question, I am not sure I understand what you mean. The usual way to divide a large gallery display into manageable portions is by providing pagination controls, as I did in the above example. There are earlier topic with more elaborate examples, such as:
Limiting search results to attachment tags/”Justifying” gallery grids
If you can tell me more about your application goal I can give you additional guidance. Thanks for your interest in the plugin.
Thank you David for your time and kind answer.
I might be missing something, but i do not want a search form. I want to display images where image name is *like* (not equals to).
I have image files with names (actual file names) like this:
SKU001z.jpg, SKUDND.jpg, SKUSome.jpg, SKUen.jpg, etc.
I was hoping for a way (shortcode maybe) to display (n) number of images where (file name) is LIKE “SKU” <– begins with “SKU”.
Note: If file name can’t be used, we could use tags for the “like” function.Regarding my 2nd question, i display certain number of images in a tab in WooCommerce.
Some users want to see more images and i want to send them off to an album page that contains all the related images. I really do not want to use pagination in the WooCommerce product page.I hope i made it clearer. Thanks again.
Thanks for your update and clarifications.
Regarding your first question, you can use the “Simple Custom Field Parameters” for
[mla_gallery]
to look for patterns in items’ file names. The actual file name is stored in a hidden custom field, so you can code something like:[mla_gallery] meta_key="_wp_attached_file" meta_value="^[0-9]{4}/[0-9]{2}/SKU" meta_compare="REGEXP" posts_per_page=3 [/mla_gallery]
to find files beginning with “SKU”. The
[0-9]{4}/[0-9]{2}/
portion of the pattern is required if your uploads are organized by year and month. If not, you can omit this portion of the pattern, i.e.,meta_value="^SKU"
. Theposts_per_page
parameter will limit the number of items displayed.Regarding your second question, if you are using
[mla_gallery]
to display the three images on the WooCommerce product page you can use themla_link_href
parameter to alter the URL of the link behind each thumbnail image. The first[mla_gallery]
shortcode in the example above shows how this can be done. You would need to change{+new_url+}
to your destination page and change the query parameters from?mla_paginate_current={+new_page+}&tax_input[attachment_category]="{+query:attachment_category,text+}"
to whatever you need to pass the selection criteria to your destination page. At the destination page you would use something like the{+request:tax_input.attachment_category+}
portion of the example to copy the criteria from the query arguments into your shortcode. If you need more specific guidance, post the source text of the shortcodes you’re using and I will have a look at them.Thank you very much indeed. I have had some success.
I really did not want to bother you with all the details but i am stuck half-way.
My users are constantly uploading images that have certain naming scheme (SKU+YYMMDDn) and are used in WooCommerce. I am including the last 3 images uploaded.
To pull those images i store the product SKU into a variable ($sku):global $product; $sku = $product->get_sku();
and then i echo the MLA shortcode as follows:
echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3[/mla_gallery]:' );
I got success with the shortcode – Thanks again Dave.
What i did not manage to do is to link all of the 3 images to a gallery page that would display ALL the images based on the same criteria (meta_value=”^[0-9]{4}/[0-9]{2}/’. $sku .'”)
I have created a Gallery page (domain.com/gallery-page/) and have the following code in it:
[mla_gallery attachment_tag="{+request:tax_input.attachment_category+}"]
I am not sure if what i am trying to achieve is doable. Either way, i am satisfied with the support and effort you have made, and i am ready to mark this as resolved.
Thanks for the kind words and for your progress report. Thanks as well for posting the code and shortcode text for your application; very helpful.
You can complete you application by making a couple of changes to what you already have. First, add an
mla_link_href
parameter to yourdo_shortcode()
statement to change the URL behind the three thumbnail images. You can try something like:echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3 mla_link_href="{+site_url+}/gallery-page/?pattern=' . $sku . '"[/mla_gallery]' );
You may need to url-encode the second
$sku
depending on its content. Second, replace theattachment_tag="{+request:tax_input.attachment_category+}"
parameter in your[mla_gallery]
shortcode with the same criteria you have in thedo_shortcode()
:[mla_gallery] meta_key="_wp_attached_file" meta_value="^[0-9]{4}/?[0-9]{2}/?{+template:{+request:pattern+}|an-invalid-sku+}" meta_compare="REGEXP" [/mla_gallery]
The template portion of the
meta_value
will pick up the pattern passed in from the previous page. Thean-invalid-sku
will prevent the default display of everything in the Media Library if the page is accessed without a pattern query argument.I hope that gets you the results you need. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions.
-
This reply was modified 8 years, 3 months ago by
David Lingren.
I can’t thank you enough, Dave.
This has worked beautifully.Superb plugin, and an unbelievable support and dedication.
God bless.How can I paginate the gallery-page?
i tried adding:posts_per_page=12 mla_output="next_page,last" mla_link_text='← Next Gallery Page' mla_rollover_text="Next or last page for this tag"
but all what i got was:
← Previous Gallery Page
← Next Gallery Page
with no images anywhere on any page.Thanks for the positive feedback!
Have a look at my first post, with the form and the two
[mla_gallery]
shortcodes. The first[mla_gallery]
displays the pagination controls, and the second[mla_gallery]
displays the images. Themla_output
parameter selects what the short displays, either pagination controls or “gallery” (the default) to show the gallery images. You need both shortcodes. Both of the shortcodes must have the same data selection parameters, e.g., themeta_key
,meta_value
andmeta_compare
. There are additional examples in the “Support for Alternative Gallery Output, e.g., Pagination” section of the Settings/Media Library Assistant Documentation tab.Good luck with the rest of your application.
Thank you, David !
I am yet to try the pagination.The first [mla_gallery] needs some tweaking.
Case: some products do not have an SKU, and the MLA shortcode still pulls 3 images from the wordpress gallery. I am not sure based on what.
I could not find the relation between empty SKU and the images displayed. However, they are the same 3 images in every product that has no SKU.
This is the code i am using to get the 3 images:
echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3 mla_link_href="{+site_url+}/gallery-page/?pattern=' . $sku . '"[/mla_gallery]' );
Is there a way to not display anything, or, to display text when meta_value does not exist?Note: clicking any image takes me to an empty gallery-page, which is a correct behavior.
UPDATE: I will try and set the condition in my config file and create the appropriate shortcode there.
Here goes a conditional working code:if (empty($sku)) { echo 'No images uploaded yet'; } else { echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3 mla_link_href="{+site_url+}/gallery-page/?pattern=' . $sku . '"[/mla_gallery]' ); }
-
This reply was modified 8 years, 3 months ago by
Abdullah Ali.
Your “empty SKU” results are similar to the “no pattern” condition I mentioned in my last post:
The
an-invalid-sku
will prevent the default display of everything in the Media Library if the page is accessed without a pattern query argument.If the
$sku
is empty, themeta_value
pattern will match everything with the “YYYY/MM/” prefix, i.e., everything in the uploads area.The
if (empty($sku)) {
code you came up with is a fine solution. You could also set the$sku
to something likean-invalid-sku
which would not match anything, but running the shortcode for that case is pointless and your solution is a bit faster.Thanks Dave.
I try to add any new info here because it might just help someone else.I am back with one more request/question:
The gallery page i am linking to does not take theattachment_category
into account, thus, it’s displaying images that are not relative but has the correctpattern
`.To save you the hassle of scrolling up, i am using the following to pull images:
echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" attachment_category=completed meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3 mla_link_href="{+site_url+}/gallery-page/?pattern=' . $sku . '" [/mla_gallery]' );
and i use the following in my “gallery-page”:
[mla_gallery columns=1 ids="{+request:current_id+}" size=medium]
P.S: If there is no easy solution, i will just have to use a different name scheme for my uploads and re-name existing ones. (i.e: from ‘SKU+YYMMDDn’, to ‘SKU+YYMMDDn-comleted’
Sorry to keep troubling you with new findings.
-
This reply was modified 8 years, 3 months ago by
Abdullah Ali. Reason: typos
Thanks for your update; new findings are not a trouble.
I am confused by the shortcode you gave for your “gallery page”. I don’t see
current_id
in thedo_shortcode()
portion orpattern
in the gallery page shortcode. I hope the gallery page shortcode is something more like:[mla_gallery] attachment_category=completed meta_key="_wp_attached_file" meta_value="^[0-9]{4}/?[0-9]{2}/?{+template:{+request:pattern+}|an-invalid-sku+}" meta_compare="REGEXP" [/mla_gallery]
If the
attachment_category=completed
is always used you can simply add it to the gallery page shortcode, as I did in the above example. If it changes, you can pass the value from thedo_shortcode()
portion to the gallery page:echo do_shortcode( '[mla_gallery] size=medium meta_key="_wp_attached_file" attachment_category=completed meta_value="^[0-9]{4}/[0-9]{2}/'. $sku .'" meta_compare="REGEXP" posts_per_page=3 mla_link_href="{+site_url+}/gallery-page/?pattern=' . $sku . '&attachment_category={+query:attachment_category+}" [/mla_gallery]' );
and
[mla_gallery] attachment_category={+request:attachment_category+} meta_key="_wp_attached_file" meta_value="^[0-9]{4}/?[0-9]{2}/?{+template:{+request:pattern+}|an-invalid-sku+}" meta_compare="REGEXP" [/mla_gallery]
One of those solutions should work for your application. If I did not understand the examples you gave, let me know.
Working like a charm.
You are amazing man. Thank you!
- The topic ‘album name begins with (like)’ is closed to new replies.