wvuweb / cleanslate-cms

A place to file issues and view releases for CleanSlate CMS. http://cleanslatecms.wvu.edu
6 stars 0 forks source link

Getting tags/labels dynamically from custom page/site data doesn't work #256

Closed adamjohnson closed 4 years ago

adamjohnson commented 4 years ago

Steps to reproduce the issue

The goal is the be able to specify tags for a page/blog article in the CleanSlate UI. Consider the following code:

<h6>Getting pages via tags and page id's BROKEN</h6>
<r:get_page id="1176">
  <r:articles:each tags="{$alternate_url}" tags_op="all">
    <h4><a href="<r:article:url />"><r:article:name /></a></h4>
  </r:articles:each>
</r:get_page>

This code can be found on my sandbox site. I use the code above on the Content Test 2 page in the sidebar in a Radius Snippet.

I'm trying to set the names of the labels via Custom Page Data, specifically the alternate_url field (makeshift Custom Page Data name, don't @ me). I'd also like to use Custom Site Data, but stuck with Custom Page Data for this issue.

Results

No pages are returned.

Expected results

It should return one blog post: "Whovian Theorem".

Hardcoded tags

Curiously, if you hardcode the tags, another_page and yet_another_page into the code above, it returns the correct results:

<h6>Getting pages via tags and page id's BROKEN</h6>
<r:get_page id="1176">
  <r:articles:each tags="another_page,yet_another_page" tags_op="all">
    <h4><a href="<r:article:url />"><r:article:name /></a></h4>
  </r:articles:each>
</r:get_page>

Bug originated from @msmoirai.

nreckart commented 4 years ago

The custom data you are trying to used is assigned to the 'Content Test 2' page; however, you then switch to the blog page via <r:get_page id="1176">, which has no value for the alternate_url custom data field. Everything with a <r:get_page_id> tag is executed from the context of the page retrieved.

For this to behave as you would like, you'll need to assign the 'alternate_url' custom data to a new variable before executing the <r:get_page_id>.

<r:set_var name="alt_url" value={$alternate_url}" />
<h6>Getting pages via tags and page id's BROKEN</h6>
<r:get_page id="1176">
  <r:articles:each tags="{$alt_url}" tags_op="all">
    <h4><a href="<r:article:url />"><r:article:name /></a></h4>
  </r:articles:each>
</r:get_page>

@adamjohnson @msmoirai

adamjohnson commented 4 years ago

I added this as a FAQ to our Blog page on CleanSlate CMS.

Thanks again.