In a comments template of mine up at the very top, before I use any entries tags like:
{exp:comment:entries weblog="news" sort="{sort}" paginate="both" limit="3"}I have the following code:
{if segment_4 == "desc"}
Assigning variable sort to: desc
{assign_variable:sort="desc"}
{if:else}
Assigning variable sort to: asc
{assign_variable:sort="asc"}
{/if}
Even though segment 4 is: {segment_4}
Sort is still: {sort}The 1st output if {segment_4} is NOT “desc” is “Assigning variable sort to: asc” as it should be because the {if:else} catches and outputs the “Assigning variable sort to: asc”
However the next line “{assign_variable:sort="asc"}” in the {if:else} does not process even though the first line(the HTML) processes. In fact it is the “{assign_variable:sort="desc"}” that processes as evidence by the last line in the output “Sort is still: {sort}” which process to “Sort is still: desc” and if I change “{assign_variable:sort="desc"}” to something like “{assign_variable:sort="xxx"}” it will indeed output {sort} as “xxx” even though it says “Assigning variable sort to asc”.
In other words, in what should be either:
Assigning variable sort to: desc
{assign_variable:sort="desc"}OR
Assigning variable sort to asc
{assign_variable:sort="asc"}based on if the if conditional is met, actually pulls the ... HTML from one and processes the {assign_variable} tag from the other if the if conditional is NOT met. (It works correctly if the if conditional IS met by {segment_4} being “desc” and outputs “Assigning variable sort to: desc”)
Obviously my gripe is I can’t get my {sort} variable to store “asc” even though my if conditional is NOT met (I want “asc” to be the deault, and {sort} to turn over to “desc” only if it is explicitly in segment_4 of my url).
By the way, when {sort} is used in the rest of my template, it behaves as it was outputted “Sort is still: desc” making my comments descending and if I force {sort} to become “asc” by changing
Assigning variable sort to: desc
{assign_variable:sort="desc"}to
Assigning variable sort to: desc
{assign_variable:sort="asc"}so both if and else assign “asc” to {sort} it behaves as you would expect it to changing the order of my comments to ascending and reporting that “Sort is still: asc”
There must be something stupid that I’m missing, not to mention I just spun my head (and probably yours) in circles trying to explain my problem. 😖