XenOptions not working in Template Modifications Find

AndyB

Well-known member
My goal is to have an easy way to change the position of any of my add-ons in the sidebar.

I have created an add-on called Sidebar Hooks, the idea is that this add-on will be required to position any of my sidebar add-ons.

The Sidebar Hooks Template Modification modifies the "forum_list" template like this:

pic001.webp
Then in the Options of portion of all my add-ons which will show in the sidebar I will include the following:

pic002.webp

The problem is the add-on Template Modification appears to not work in the "Find" field if it's trying to find code which has been added by another add-on using the Template Modification.

Example of Template Modification (template = forum_list) with the Find not working using a $xenOptions.

pic003.webp

Thank you for taking the time to look at this issue.
 
Last edited:
This Template Modification does work as it's not using the xenOptions in the Find field.

pic004.webp
 
I just tried adding the Positions into the forum_list template directly, but that doesn't work either.

pic005.webp

It appears that in Template Modifications you cannot use $xenOptions in the Find field.
 
This is what I have tried. The Template Modification was changed to:

pic001.webp

And that calls the following PHP file:

PHP:
<?php

class Andy_Traffic_RegexTM
{
    public static function getCallback($matches)
    {
		return 'Position 1';
	}
}

The result is this in my sidebar:

pic002.webp
 
The problem is the add-on Template Modification appears to not work in the "Find" field if it's trying to find code which has been added by another add-on using the Template Modification.
You cannot find content added by other template modifications.

The Test Modification button should show that, as would the template contents that appear; you should not see any other TMs that have applied to that template.
 
You cannot find content added by other template modifications.

Hi Chris,

Thank you for taking the time to look at this thread.

In my testing (see post #3) I tried putting the <xen:comment>Position 1</xen:comment> comments directly into the forum_list template and even then the xenOptions will not work in the Find field. So it appears $xenOptions is not currently supported in the Find field of Template Modifications.
 
I don't think comments are supposed to work for that anyways. I could be wrong. But you can put hooks into the template and do a find replace on them. That for a fact works.
 
I don't get what doesn't work about it.
gfgdfgh.webp

I found the comment here just fine, unless I misunderstand the issue?
 
even then the xenOptions will not work in the Find field.
In post # 3 the forum_list template doesn't even contain xenOptions.

Just simplify the test case:

1) Create a new template in the Master Style called: tm_test
2) Add the following content to it: {$xenOptions.boardUrl}
3) Create a new template modification, applied to tm_test. Find: {$xenOptions.boardUrl} replace {$xenOptions.boardTitle}
4) Edit the forum_list template, at the top place <xen:include template="tm_test" />. Go to the forum list.
5) Result: You will see the board title instead of the board URL. Therefore, it works fine.

Whatever problems you are having, it isn't that.

Despite what I said earlier, it should in theory be possible to find/replace on the replacements of previous TMs but make sure you use a logical execution order.
 
I don't understand what you're trying to do and the relations between the different elements you give:
What's the relation between the template modification with many comments, the one with the $xenOptions variable, and the option showed?

If I look what you try to do and revert the idea, here's what I get:
You create some text hooks in a template using a template modification. Based on those hooks, you create a new template modification that targets one of the comment to insert a custom html code. This will work without any problem providing the templates modifications order is correct (first mod must perform before the second one). So now, you're thinking of creating a new layer of code to allow to target these comments by a XenForo option. Here's a possible loophole: the template modifications are not applied in live (when the page is loaded), so if you think to insert a XenForo option in the find box and that this option will look for the actual value of this option to perform the replacement, you're mistaken. It will only look for the text your enter in the find box, nothing more. Don't forget also that the xenforo comments are strip in the final output. I think you need to rethink your process.
 
so if you think to insert a XenForo option in the find box and that this option will look for the actual value of this option to perform the replacement, you're mistaken. It will only look for the text your enter in the find box, nothing more.

This is exactly what I have found to be the case. Although there appears to be one exception to this rule, I have found that {$xenOptions.boardTitle} will work, but that won't be useful for my needs.
 
This is exactly what I have found to be the case. Although there appears to be one exception to this rule, I have found that {$xenOptions.boardTitle} will work, but that won't be useful for my needs.
Just to be sure we're talking about the same thing.
Let's suppose the variable {$xenOptions.boardTitle} value is "My Board". When you create a template modification and search for "{$xenOptions.boardTitle}" in the search field, it will really look for the text "{$xenOptions.boardTitle}", not its value "My Board". You an create a new xenForo option, insert it in a template, create then a template mod, find this variable name in template, then replace it with something else, it will work. The template modification system is really like a standard search/replace system on the template text content. Using a callback will not change this. If you need to work with the output code, use the template hooks or inject variable in a template using the template create listener.
 
Create a new template modification, applied to tm_test. Find: {$xenOptions.boardUrl} replace {$xenOptions.boardTitle}

Hi Chris,

It appears {$xenOptions.boardTitle} is the only exception as that works. Please try a test using another $xenOptions and see if you come to the same results as I have in that $xenOptions will not work in Template Modifications "Find" field excluding the one exception as previously stated.
 
Let's suppose the variable {$xenOptions.boardTitle} value is "My Board".

Hi cclaerhout,

First thank you for your time, I really appreciate this.

What I have found in my testing is that {$xenOptions.boardTitle} is the only exception to the rule. If I try for example {$xenOptions.trafficPosition} or any other type of $xenOptions.foobar} in the Template Modifications "Find" field, it will not work.
 
It works fine, Andy.

upload_2014-11-14_15-45-46.webp

You need to start again and explain steps in detail which lead you to it not working.

It's not completely clear how to reproduce the issue you're reporting.
 
I have an add-on called Traffic.
In the Options page of the Traffic add-on I have a field called Position

pic001.webp

The Option ID = trafficPosition

I have added the following to the forum_list template:

pic002.webp

I have create a Template Modification for Traffic and it looks like this:

pic003.webp

So what should happen is that the "Find:" should have a value of "Position 1", and should be be replaced by the contents in the "Replace:" box.
 
Your template does not contain {$xenOptions.trafficPosition}, it contains Position 1.

It doesn't work how you think it should.
 
Top Bottom