SparkDevNetwork / Rock

An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
http://www.rockrms.com
577 stars 348 forks source link

Setting a Context Parameter in HTML Content Block erases the HTML #5923

Closed leahjennings closed 2 months ago

leahjennings commented 3 months ago

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

{% 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 %}

There are not any courses that match the info provided.

{% endif %}


- Notice that no matter if you load the page with our without a page parameter, it loads the content as expected
<img width="899" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/d1cb9839-3a26-47b2-b038-12f45a6d4d78">
<img width="875" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/3a2b00f8-ea81-41d1-98c7-25e26f1835a0">

- Edit the Block Settings again
- Set `ContextParameter` to CourseGuid
<img width="988" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/2e130d26-f13c-459d-b93b-491b33aa585f">

- Notice that when you reload the page, whether or not there's a parameter in the URL, the results are blank
<img width="883" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/1d66dff9-44ca-4bc9-9629-938df379c3e7">
<img width="895" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/042190b9-ab85-4643-a195-3a23051989e1">

- 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
<img width="1219" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/d3577d69-11d9-4aa6-9ab3-a7cbde837eab">

- 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


<img width="1728" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/fbf0d9a4-cd5f-42c5-9dc5-cf8cb52d9aa5">

- Notice there is version history in the results, but the block shows version 0
<img width="1728" alt="image" src="https://github.com/SparkDevNetwork/Rock/assets/66277785/f3975f4e-9bad-4e74-91d2-6da9c234f6b5">

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](https://github.com/issues?q=is%3Aissue+user%3ASparkDevNetwork+-repo%3ARock) to see if your bug or enhancement is already reported.
- [X] Reproduced the problem on a fresh install or on the [demo site](https://rock.rocksolidchurchdemo.com/).

### Rock Version

Rock McKinley 16.4 (1.16.4.4)

### Client Culture Setting

en-US
chead4 commented 3 months ago

@leahjennings Hi Leah, context parameters can be a little tricky. When setting up a Context Parameter, you'll need to enter the content (Edit HTML) for each unique parameter. The content entered is not shared across parameters. By entering content for each parameter, you also gain the ability to use Display from dates, versioning and approval for the content.

We've also reviewed the documentation and will take this opportunity to polish it further.

Let me know if you have any questions.

chead4 commented 2 months ago

@leahjennings Hi Leah - I will be closing this issue at this time. Please reach out if you have any questions.