MODx & Gallery component - how to handle non-existing albums? - modx

Referrencing non-existing albums in the Gallery component results with the following warning & error:
Warning: Invalid argument supplied for foreach() in
/home/user/domain.com/core/cache/includes/elements/modsnippet/17.include.cache.php on line 106
Fatal error: Cannot use string offset as an array in
/home/user/domain.com/core/cache/includes/elements/modsnippet/17.include.cache.php on line 165
And here is how I reference albums:
[[!Gallery? &album=`[[*alias]]` &limit=`20` &thumbWidth=`90` &thumbHeight=`90`]]
Album names match page's aliases. Everything works fine if albums exist - I would like to display blank album (no content), if no matches found.
Any ideas? I am using MODX Revolution 2.2.4-pl (traditional).
Thanks, Luke

try this:
[[*alias:notempty=`[[!Gallery? &album=`[[*alias]]` &limit=`20` &thumbWidth=`90` &thumbHeight=`90`]]`]]
oh, wait! you are linking [[*alias]] to your album in Gallery. you should use your own TV like [[*album]] instead.

Here is how I got it working...
Each page has corresponding gallery created with page's alias as gallery name. Some galleries are left blank.
Luke

Related

How do I add a youtube video to my site's meta tag?

This post says it is easy to add a youtube video but I could not find any tips.
How to add facebook video into og:video meta tag?
Google says you should not add iframe tags to the head as on:
"Don't use invalid elements in the
No element other than the aforementioned is permitted by the HTML specification in the head. Common elements that appear in the head, rendering it invalid are:
iframe
img
We strongly recommend that you don't use these invalid elements in the head, but if you must, place these invalid elements after the ones you want Google to see. Once Google detects one of these invalid elements, it assumes the end of the head and stops reading any further elements in the head."
https://developers.google.com/search/docs/crawling-indexing/valid-page-metadata
I do see search results that indicate a site a video alongside. How can I do that?
just use the iframe tag and copy the youtube url into src it should look something like this
<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY">
</iframe>

How to load wikipedia.page().content when the page title has parentheses

I would like to load the content of a number of related pages for keyword analysis. But when the page title contains parentheses it strips the parentheses and subsequently gives an error. How would I go about loading the content of pages that contain parentheses in the page title? e.g.
https://en.wikipedia.org/wiki/Oil_pump_(internal_combustion_engine)
import wikipedia
automotivedata = wikipedia.page("Oil_pump_(internal_combustion_engine)").content
PageError: Page id "oil_pump_ internal combustion engine" does not match any pages. Try another id!
Just ignore the brackets. Something like this:
print(wikipedia.page("Oil_pump_internal_combustion_engine").content)
September 23, 2019: Issue opened on GitHub (https://github.com/goldsmith/Wikipedia/issues/214)

Kentico 9 blog main page, archive page, and tag page

I'm new to Kentico, and have spent hours trying to make the blog work but haven't had any luck. Hope someone could help. I created a new blog by [a] using Pages > New Page > Blog; [b] then applying the Blog page template to it; [c] after that I created 2 sample blog posts. The only thing that works is the individual blog post. Other things don't work:
1- the blog main page --> empty
2- the blog archive page (for July) --> empty
3- tag link --> error message "Page /Blogs/My-blog-1.aspx was not found." Although I know I can change the tag link url, not sure what should be in there.
4 - making "Blog" appears on my nav (that I used CSS List menu web part). For this one, as a workaround, I was thinking about adding a blank "Blog" page and had it redirected to the blog url.
I've read the documentation related to Blog, but couldn't make it to work. Thanks for help!
Some of the out of the box templates are setup in such a way to only work on some of the example site templates which is why you're getting these results.
In the rptAllPosts repeater, set the Path property to ./%, ensure the Page types property is set to cms.blogpost, make sure you have a value in the Transformation property as well.
Should be resolved when you finish #1
You will have to modify the Selected Transformation. If you're using the default transformation, about line 9, way at the end you will need to modify the last parameter from ~/Blogs/my-blog-1.aspx to ~/Blog. This should fix the blog tag link.
Your work-around is very common and I'd stick with it for now.

How can I grab part of MediaWiki page title?

In MediaWiki 1.26.2, how can I grab part of a page title to use it in a #ifexist statement?
I need to link to different but related articles in MediaWiki, alerting the user if a page exists or do not. For that I did the following:
I have a page named ARTICLE_NAME. Associated with it is a page named Notes:ARTICLE_NAME. "Notes:" is not a namespace, but a string as ARTICLE_NAME is. I cannot create a namespace for Notes due to policy restrictions.
In ARTICLE_NAME page, the following code goes to check if the notes exists:
{{#ifexist: Notes:{{PAGENAME}} | {{alert_box}} | }
So if ARTICLE_NAME has a related Notes:ARTICLE_NAME page a I get a nice custom alert box highlighting the fact and linking to it.
My problem begins when I try the inverse. In the Notes:ARTICLE_NAME page, I need the notes to display an alert box if there is a page named ARTICLE_NAME. The code
{{#ifexist: {{PAGENAME}} | {{alert_box}} | }
Does nothing because {{PAGENAME}} brings Notes:ARTICLE_NAME as expected.
How can I get whatever comes after the "Notes:", using that instead of {{PAGENAME}} to check it with the #ifexist code?
It works by combining #pos with #ifeq.
Example:
{{#ifeq:{{#pos:text1|text2}}| |text1 does not contain text2|text1 contains text2}}
So after mucking around I found a way: remove the Notes: from the pagename then put it against the #ifexist.
{{#replace: {{PAGENAME}}|Notes:|}}
This way it replaces the Notes: with nothing. I made that a magic word named ARTICLE_TITLE, so the code that goes to notes is this:
{{#ifexist: :{{ARTICLE_TITLE}} | {{Alert_box}} | }}

article:publisher meta tag cannot be parsed as profile

According to this update...
https://developers.facebook.com/blog/post/2013/06/19/platform-updates--new-open-graph-tags-for-media-publishers-and-more/
...I thought article:publisher (with page ID or URL) would put a like button for the representative page when shared links are posted to walls? The debugger seems to think differently... what am I missing?
Debugger info:
Object at URL 'http:// domain.com/post/' of type 'article' is invalid because the given value 'http:// www.facebook.com/mypage' for property 'article:publisher' could not be parsed as type 'profile'
article:publisher is for Facebook pages, article:author is for individuals.
The "Follow" and "Like" buttons will only appear for people who haven't already followed the author or liked the publisher page.

Resources