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

Running into a bit of an issue with template modifications

Discussion in 'XenForo Development Discussions' started by Jake B., Oct 8, 2014.

  1. Jake B.

    Jake B. Well-Known Member

    I'm trying to make it so you can set a rel and target attribute on navigation li
    nks using $extraTabs. It is working fine on the default theme with the following settings:

    Find:
    Code:
    <a href="{$extraTab.href}" class="navLink">
    Replace:
    Code:
    <a href="{$extraTab.href}" class="navLink" rel="{$extraTab.rel}" target="{$extraTab.target}">
    However, on UI.X it obviously would not work due to the large amount of changes made in the navigation template, so to make things a bit easier I created a second template modification with the following:

    Find:
    Code:
    <a href="{$extraTab.href}" class="navLink{xen:if '!@uix_alwaysShowNavDropdownArrow', ' NoPopupGadget'}"{xen:if '!@uix_alwaysShowNavDropdownArrow', ' rel="Menu"'}>
    Replace:
    Code:
    <a href="{$extraTab.href}" class="navLink{xen:if '!@uix_alwaysShowNavDropdownArrow', ' NoPopupGadget'}"{xen:if '!@uix_alwaysShowNavDropdownArrow', ' rel="Menu {$extraTab.rel}"', ' rel="{$extraTab.rel}"'} target="{$extraTab.target}">
    But it is not modifying the navigation template for UI.X.

    Here is what it's showing me on the template modifications page:
    template_modifications.PNG

    This is for the default one:
    modification_log_default.PNG

    And the UI.X one:
    modification_log_UI.X.PNG

    I cannot figure out why the apply count is at zero.. I haven't done much using the template modifications, so it is probably just something stupid I have missed.
     
  2. Steve F

    Steve F Well-Known Member

    It is showing zero because you're searching for something that doesn't exist in the master style, in your second modification. Modifications are not style based so you can't search for a modified line from another style.

    To further extend it, a regex replacement will be needed.
     
    Last edited: Oct 8, 2014
  3. Jake B.

    Jake B. Well-Known Member

    I've tried a few different ways to do a regex replacement, but have not gotten it to work correctly.
     
  4. Mike Creuzer

    Mike Creuzer Well-Known Member

    Find class="navLink and replace that. Its proper anyways, I mean the way you do it there any theme that modifies links it won't work.
     
    Last edited: Oct 8, 2014
    Chris D likes this.
  5. Brogan

    Brogan XenForo Moderator Staff Member

    Do the find on the default template code.
     
  6. Jake B.

    Jake B. Well-Known Member

    Then you run into the issue of having a link that has two rel attributes because of this:

    Code:
    {xen:if '!@uix_alwaysShowNavDropdownArrow', ' rel="Menu"'}
    That's what I did originally, however UI.X's navigation template was changed too much for it to find in both.

    Also, if you add nofollow or noreferrer to the rel="Menu" it makes the dropdown stop working.
     
    Last edited: Oct 8, 2014
  7. Mike Creuzer

    Mike Creuzer Well-Known Member

    Then in that case, you'll want to check if there is a rel="*" and replace it with rel="{1} $whatever_here". I am trying to see how I can do what I want with UI.X (toggleable dropdown menus) and yet still work with plugins. Some clever regex is the only solution, so I think what we might do is convert that setting to a plugin in the future :/
     

Share This Page