1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can I find and replace multiple lines in Template Modifications?

Discussion in 'XenForo Development Discussions' started by Joe Link, Jan 7, 2015.

  1. Joe Link

    Joe Link Well-Known Member

    I'm sure this is possible, but after two hours of trying to figure it out, I'm asking :confused:

    I'd like my modification to replace the first piece of code with the second, in the navigation tab.

    Code:
                    <a href="{$extraTab.href}" class="navLink">{$extraTab.title}<xen:if is="{$extraTab.counter}"><strong class="itemCount"><span class="Total">{$extraTab.counter}</span><span class="arrow"></span></strong></xen:if></a>
                    <a href="{$extraTab.href}" class="SplitCtrl" rel="Menu"></a>
    Code:
                    <a href="{$extraTab.href}" class="navLink NoPopupGadget" rel="Menu">{$extraTab.title}<xen:if is="{$extraTab.counter}"><strong class="itemCount"><span class="Total">{$extraTab.counter}</span><span class="arrow"></span></strong></xen:if></a>
                    <xen:comment><a href="{$extraTab.href}" class="SplitCtrl" rel="Menu"></a></xen:comment>
    
    For whatever reason, I can't find a way to tell it to 'find' both lines of code. If I enter a single line, it works fine.

    Thanks guys.
     
  2. AndyB

    AndyB Well-Known Member

    When the text to replace is not continuous, you will need to create two Template Modifications.
     
    Last edited: Jan 7, 2015
    Joe Link likes this.
  3. Joe Link

    Joe Link Well-Known Member

    Ah, I was wondering about that.

    Thanks for the reply!
     
  4. EQnoble

    EQnoble Well-Known Member

    You can do it with regex, you would need to make the template content that is matched between the two pieces (which you need to replace) it's own capture group and then reference it in the replace string in between your two new replacement string parts.
     
  5. Joe Link

    Joe Link Well-Known Member

    Is that a path a beginner such as myself should wander down at this point, or should I stick to learning the basics for now? :D
     
  6. EQnoble

    EQnoble Well-Known Member

    That is up to you, I learned regex without knowing what it was a few years ago. The good thing about template mods vs using regex to make changes in your db is that you can easy change or delete a template mod with no loss of data so if you are going to try there is never a better time <shrug>. S'all up to you really.
     
  7. Joe Link

    Joe Link Well-Known Member

    Much appreciated! I'll look into it. Sounds like it could save me some time in the long run.
     

Share This Page