• Resolved cuckoofairweb

    (@cuckoofairweb)


    Hi, this is probably similar to other error report. On the above page I am getting this error:
    Warning: array_key_exists() expects parameter 2 to be array, unknown given in /homepages/2/d451850435/htdocs/app451850410/wp-content/plugins/media-library-assistant/includes/class-mla-shortcode-support.php on line 798

    It’s repeated 6 times and appears before the first line of text.

    The HTML of the page is this:

    <a id="topofpage"></a>Here's the 'phrases' that have been used to 'tag' each photo in the gallery. The larger the text the more photos there are of that phrase. Click a phrase to see its photos displayed below.
    
    [mla_tag_cloud taxonomy="attachment_category,attachment_tag" number=0 post_mime_type=image/jpeg exclude="70,97,73,74,151,74,75,96,110,162,172,173,175" separator=" | " mla_link_href="{+page_url+}?current_id={+term_id+}&current_name={+name,url+}"]
    
    [mla_gallery post_mime_type="a-bad-type" mla_nolink_text="{+template:(
    <h3>Here's the photos for {+request:current_name+}</h3>
    Click a photo to enlarge it in the slideshow display, once there click the photo to display the next one. Click on the background page to return here.)+}"][/mla_gallery]
    
    [mla_gallery]
    post_mime_type=image/jpeg
    tax_query="array (
    'relation' => 'OR',
    array ( 'taxonomy' => 'attachment_category',
    'field' => 'id',
    'terms' => array( {+request:current_id+} ),
    'include_children' => false,
    ),
    array ( 'taxonomy' => 'attachment_tag',
    'field' => 'id',
    'terms' => array( {+request:current_id+} ),
    ),
    )"
    orderby=date
    order=ASC
    size=icon
    link=file
    mla_alt_shortcode=justified_image_grid
    [/mla_gallery]

    I am running WordPress 5.8 running Responsive Mobile theme

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your report. I regret the trouble you’re having with the latest MLA version. The PHP Warning message is a result of an MLA change I made in v2.96.

    I have released MLA version 2.97, which corrects the problem and has a few other improvements as well. I am marking this topic resolved, but please update it if you have any trouble with the latest version.

    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    Hi David,

    As ever thanks for the prompt response and for adding in the description field too – a nice bonus.

    A quick once over on the web site has highlighted that the above page and code now:
    * displays all images on initial load but without the opening header that gets displayed if you click a term in the tag cloud
    * The display of all images includes one (the penultimate one – Zac and the Zeroes that has no valid Att Categories or Att Tags!)

    Thanks

    Paul

    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    Hi David I’m not sure if you’ve seen my updated description of what now happens after the initial fix.

    The page now displays all images when it is first opened but without this header text (the choice was for ‘the Plonkers’):
    “Here’s the photos for The Plonkers
    Click a photo to enlarge it in the slideshow display, once there click the photo to display the next one. Click on the background page to return here.”
    This header text is displayed properly when the any category link is displayed.

    Also, on the initial opening of the page all images are displayed including those without any of the selected categories – I exclude several that aren’t relevant for the tag cloud.

    Thanks

    Paul

    Plugin Author David Lingren

    (@dglingren)

    I regret that I did not understand your first update. Thanks for trying again.

    The missing “header text” is a result of your content template. You have parentheses around the entire text, which means the text is suppressed when there is no value for the {+request:current_name+} substitution parameter. You can try this alternative:

    mla_nolink_text="{+template:(<h3>Here's the photos for {+request:current_name+}</h3>)
    Click a photo to enlarge it in the slideshow display, once there click the photo to display the next one. Click on the background page to return here.+}"
    

    Note that I have moved the closing parenthesis to the end of the header tag, so the “click a photo…” always appears. You could also try something like:

    mla_nolink_text="{+template:<h3>Here's the photos for {+template:{+request:current_name+}|all tags+}</h3>
    Click a photo to enlarge it in the slideshow display, once there click the photo to display the next one. Click on the background page to return here.+}"
    

    That should display “all tags” or the selected tag.

    The “all images are displayed” issue is happening because your [mla_gallery] tax_query does not have any exclusion clause for the terms excluded from the cloud. I will have to do some experimenting to give you the syntax of an exact solution. I will post an update when I have progress to report.

    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    David,

    I’m very sorry but having written a poor post I have now confused you as well!

    The way the page used to work was that:
    On initial load it’d just display the tag cloud, no images would be displayed. Hence the opening text “Here’s the ‘phrases’ that have been used to ‘tag’ each photo in the gallery. The larger the text the more photos there are of that phrase. Click a phrase to see its photos displayed below.”
    You’d click a term from the tag cloud and the text “Here’s the photos for <<Clicked Term>>
    Click a photo to enlarge it in the slideshow display, once there click the photo to display the next one. Click on the background page to return here.” followed by all photos with that term.

    The main issue at the moment is that somehow it displays all images as part of the initial load – ie before a term is clicked. I suspect if that is fixed then the other issue that of displaying images without the required tags will be fixed…

    Sorry for the confusion.

    Paul

    • This reply was modified 3 years, 3 months ago by cuckoofairweb.
    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    Hi I have updated the page to add some ‘debug’ code. It looks like this shortcode:

    [mla_gallery]
    post_mime_type=image/jpeg
    tax_query="array (
    'relation' => 'OR',
    array ( 'taxonomy' => 'attachment_category',
    'field' => 'id',
    'terms' => array( {+request:current_id+} ),
    'include_children' => false,
    ),
    array ( 'taxonomy' => 'attachment_tag',
    'field' => 'id',
    'terms' => array( {+request:current_id+} ),
    ),
    )"
    orderby=date
    order=ASC
    size=icon
    link=file
    mla_alt_shortcode=justified_image_grid
    [/mla_gallery]

    Is being run as part of the initial load…

    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    David,

    Hi a further update. Using WordPress’s version history I have restored the version that was created seven months ago and has worked as expected since then.

    That’s the version that’s currently running and it displays the same symptoms eg displays images on initial load with no tag cloud term having been clicked.

    Paul

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your updates and clarifications. I now understand (I hope) that the only problem you have with the current display is that on page load, all images are displayed and what you want is no images displayed; is that right?

    To display no images on the initial page load requires a simple change to your second [mla_gallery] shortcode. Try something like this:

    [mla_gallery]
    post_mime_type=image/jpeg
    tax_query="array (
    'relation' => 'OR',
    array ( 'taxonomy' => 'attachment_category',
    'field' => 'id',
    'terms' => array( {+template:{+request:current_id+}|1+} ),
    'include_children' => false,
    ),
    array ( 'taxonomy' => 'attachment_tag',
    'field' => 'id',
    'terms' => array( {+template:{+request:current_id+}|1+} ),
    ),
    )"
    orderby=date
    order=ASC
    size=icon
    link=file
    mla_alt_shortcode=justified_image_grid
    [/mla_gallery]
    

    The changes are to both of the 'terms' => tax_query parameters. I have added a template that supplies a default term ID (‘1’) when the {+request:current_id+} value is empty. The default won’t match any items and the display will be empty.

    You wrote “I have restored the version that was created seven months ago“. Did you change the WordPress version or the MLA version or the page content? I don’t know why the display would have changed.

    I hope the above suggestion gives you the results you desire.

    Thread Starter cuckoofairweb

    (@cuckoofairweb)

    Hi David,

    Many thanks the |1+ did the trick!

    Tapping into some of my previous software development techniques I restored back to the last known good working copy which was the January one when you originally helped me setup the tag cloud. The only changes since then have been to the WordPress version, possibly PHP and the updates to your amazing MLA.

    I have no idea why it suddenly stopped working ok? Maybe there was a re-coding deep in the bowels of WordPress core that changed the way in which the terms expression was parsed? If it’d help I’m happy to turn on MLA debugging?

    Regards

    Paul

    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that the suggestion was helpful.

    I don’t know when or why the terms expression parsing changed, but it was an accident that it worked in the past; no further debugging required. The template approach is the right solution.

    I am marking this topic resolved because the original issue has been addressed. If you have any problems or further questions regarding the other query-related material, start a new topic for them. Thanks for your continued interest in the plugin.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Warning: array_key_exists()’ is closed to new replies.