Rock
Rock copied to clipboard
Setting a Context Parameter in HTML Content Block erases the HTML
Description
I have written a couple of pages that will only display content when passed a Guid via a URL context parameter. I've noticed weird behavior that the block seems to have all the code erased, but haven't been able to nail down what is going until today. Apparently if I have a Context Parameter set on the HTML Content block itself, it will erase the HTML. In my tests in production, if it is passed a parameter I have used to test with, sometimes it does load properly. But any new guid for sure erases it.
I just went through the below steps to reproduce and confirmed it is consistently reproducible. Also, I know the code in the block won't really make sense on the demo site, but the blue alert info bar should show up at the least (as seen in the testing steps).
Also, I'm not entirely sure what that parameter is supposed to do. Apparently what I needed to accomplish is possible without setting that parameter.
Actual Behavior
The HTML Content block "loses" its code when a ContextParameter is set on the block.
Expected Behavior
I would expect that the HTML Content block would not lose its code if the ContextParameter setting has a value.
Steps to Reproduce
-
On the demo site, login, and go to the External site specifically
-
Click the child page icon in the admin toolbar and create a new child page
-
Go to the new page
-
Add an HTML Content block to the webpage
-
Edit the block settings and set the Entity Type to
Step Type
, and set Versioning to True -
Edit the Page Properties and add a route with page parameter of
{CourseGuid}
and name the Context Parameter the same -
Add the following code to the HTML Content block
{% assign courses = 'nsu-coursedetails' | PersistedDataset %}
{% assign course = courses | Where:'StepTypeGuid',Context.StepType.Guid | First %}
{{ PageParameter.CourseGuid }}
{% if course != null and course != '' %}
{{ course.Title | SetPageTitle }}
<h1>{{ course.Title }}</h1>
<p>{{ course.Description }}</p>
{% else %}
<div class="alert alert-info">
There are not any courses that match the info provided.
</div>
{% endif %}
-
Notice that no matter if you load the page with our without a page parameter, it loads the content as expected
-
Edit the Block Settings again
-
Set
ContextParameter
to CourseGuid -
Notice that when you reload the page, whether or not there's a parameter in the URL, the results are blank
-
If I now edit the HTML Content block, I see a blank section where the code was before, and versioning is set back to 0
-
On the internal side, go to Power Tools > SQL Command, run the following to get the block id:
SELECT TOP 1 * FROM Block b ORDER BY Id DESC
- Take that block id and put it in this query:
SELECT *
FROM htmlcontent hc
WHERE hc.BlockId = ####
ORDER BY hc.ModifiedDateTime DESC
- Notice there is version history in the results, but the block shows version 0
If you remove the ContextParameter setting from the block itself, the block behaves as expected.
Issue Confirmation
- [X] Perform a search on the Github Issues to see if your bug or enhancement is already reported.
- [X] Reproduced the problem on a fresh install or on the demo site.
Rock Version
Rock McKinley 16.4 (1.16.4.4)
Client Culture Setting
en-US