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

Template Mod - Doesn't always apply

Discussion in 'XenForo Development Discussions' started by Steve F, Feb 4, 2014.

  1. Steve F

    Steve F Well-Known Member

    I know why it doesn't apply, what I need is a solution :)

    Find:
    Code:
    <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
                </xen:hook>
    Seems pretty straight forward but I guess since there are many custom styles and even being a 'space' off will make the template mod not apply. So I'm assuming I need to use regular expression which I'm not certain how to do. Either way I need to insert my template mod at that point. What are my options? I have two add-ons I need to touch up and this is basically the final step for me before releasing.

    Any help?

    Thanks
     
  2. EQnoble

    EQnoble Well-Known Member

    Search Type:
    Code:
     *Regular expression
    Find:
    Code:
    #\<div class="breadBoxBottom">(?:[^>]+>){2}[^\<]+\</xen:hook>#siu
    Replace:
    Code:
    \0
    <yourstuff_here>
     
    Last edited: Feb 4, 2014
  3. Steve F

    Steve F Well-Known Member

    Thank You @EQnoble will test it out. :)

    I've seen a few links on the net that explain somethings with regular expression but it wasn't so user friendly to me, any ideas where I could get a better grasp on the subject?

    Thanks again!
     
  4. Vincent Gabriel

    Vincent Gabriel Active Member

    http://en.wikipedia.org/wiki/Regular_expression
     
    Steve F likes this.
  5. Steve F

    Steve F Well-Known Member

    Doesn't seem to be working, not applying.
     
  6. Vincent Gabriel

    Vincent Gabriel Active Member

    What template are you trying to modify ?
     
  7. Steve F

    Steve F Well-Known Member


    PAGE_CONTAINER
     
  8. Vincent Gabriel

    Vincent Gabriel Active Member

    Why can't you use simple replacement to search for:

    Code:
    <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
    and replace with

    Code:
    <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div> <anything else>
     
  9. Steve F

    Steve F Well-Known Member

    derp, nevermind I did not choose regular expression, thought I did :p

    Working now.

    Thanks!
     
  10. Steve F

    Steve F Well-Known Member

    Well testing on a few styles that we have that have modified page_container does not apply the template mod. I could try inside the <hook> I suppose but I just thought regular expression would be better in most circumstances.
     
  11. Vincent Gabriel

    Vincent Gabriel Active Member

    Oh yeah, that's true. different styles can change the spacing or formatting of the searched string. For me i just test this on the default theme. good point.
     
  12. RobParker

    RobParker Well-Known Member

    http://regexone.com/ is useful
     
  13. Steve F

    Steve F Well-Known Member

    Well I need assistance again with some regex, hope @EQnoble can point me in the correct direction.

    I need to find this for starters, default moderator_bar link.

    Code:
    <a href="admin.php" class="acp adminLink"><span class="itemLabel">{xen:phrase admin_control_panel_short}</span></a>
    But also, the reason I'm back, is we modify that line in our framework and the add-on I am working on is not applying the template mod. Here is the line from our framework, can the above and below have the same regex replacement?

    Code:
    <a href="admin.php" class="acp adminLink"><span class="itemLabel"><xen:if is="@xb_fa_modBar"><i class="fa fa-cog fa-lg" title="{xen:phrase admin_control_panel_short}"></i><xen:else />{xen:phrase admin_control_panel_short}</xen:if></span></a>
    I need to find the that line and be able to essentially replace it with my own.
     
  14. EQnoble

    EQnoble Well-Known Member

    First off, I am completely out of my mind so while I can give you direction...correct is not the exact adjective I would be inclined to select in application to the heading. That said I think I am understanding you correctly...I hope maybe you can clarify this for me.

    In the most basic of summarization I would say that you want a single expression capable of catching both of those code blocks?

    If so try this...
    Code:
    #<a[^>]+adminLink"><span class="itemLabel">(?:\{xen:phrase admin_control_panel_short}|<xen:if is(?:(?:.*?(?!</xen:if>?)).)(?:</xen:if>))</span></a>#siu
     
    Last edited: Jun 28, 2014
    Steve F likes this.
  15. Steve F

    Steve F Well-Known Member

    Yea exactly that :)

    Works correctly. Thank You
     

Share This Page