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

Template Changes - best practices

Discussion in 'XenForo Questions and Support' started by Ryan Kent, Mar 9, 2011.

  1. Ryan Kent

    Ryan Kent Well-Known Member

    I am making some non-CSS template changes. My question is, what's the best practice regarding these changes? Should I make them in the top-most parent? Or the bottom-most child?

    Example 1. For XenAtendo the default setting only allows setting times that are on the hour (i.e. 12:00). I need the ability to set events at other times (i.e. 12:30). To make this change I modify a variable from :00 to %i. My question is should I make the change in EWRatendo_EventScripts (Default style) or EWRatendo_EventsScripts (Flexile) or EWRatendo_EventScripts (Flexile Blue)?

    My template hierarchy is set as Default > Flexile (child of Default) > Flexile Blue (Child of Flexile).

    Example 2 is same idea but I am altering my footer. I only offer this example in case the first example was different due to it being part of an add-on, not the core product.

    My goal is for these changes to be seen in my site, yet for me to not receive Outdated Template notifications during upgrades, yet not to lose any functionality during upgrades.
  2. dieketzer

    dieketzer Well-Known Member

    how i do it.

    default (unedited- so i always have a vanilla template to refer to)
    -base theme (for nearly all edits)
    --dark theme (only edits specific to dark styles- appended to extra.css)
    ---dark01 (a dark red recolour, no template edits - only style property changes used)
    ---dark02 (a dark blue recolour, no template edits - only style property changes used)
    --light (no edits, as edits are already done in base theme)
    ---light01 (a light red recolour, no template edits - only style property changes used)
    ---light01 (a light blue recolour, no template edits - only style property changes used)
    bold = enabled for member use.

    note: any template you edit in 'base' (such as extra.css) will be inherited by children. however, if you then open that template and edit/save it in a child theme, any future edits to the base template will not be reflected in the child template.
    this is why 99% of all my edits happen in my base theme. the only child edits i will make are to extra.css- and only if i have to.
    the bonus: if i want to modify a variable from :00 to %i i only need to do it in one template in one theme(base theme, or in your case Flexile*), and all the children will inherit it.

    * this assumes you do not make the default vanilla style available to your members.
  3. dieketzer

    dieketzer Well-Known Member

    and youre going to get outdated template notifications no matter what you do.
    what matters is how well you have set up your inheritances. the better youre set up, the fewer re-edits you will have to do.
  4. Ryan Kent

    Ryan Kent Well-Known Member

    If you make all your changes in the default Flexile theme, then when Flexile is updated all your changes are lost, correct?

    I had a LOT of style edits. After I upgraded to XF 1.0.0 they remained. When I updated to Flexile 1.0 I lost a ton. My background, my header/footer customizations, my sidebar and a lot of other changes I made were all wiped out. I would prefer that to never happen again.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Parent styles are for style changes that are common to all children. Child styles create variations on the parent. The decision to use a parent or child depends on the nature of the style change.

    In your case you will probably want to store your customizations in a child of Flexile. For example, if the Flexile style has a custom header template but you want to further customize the header then you would organize your styles like this:

    Default Style
    - Flexile w/ custom header

    With this organization, you only need to upload the Flexile style as the parent. The child style is not actually the Flexile style, but rather it is just a new style created as a child of Flexile such that it inherits everything from the parent, except for the header template which you have explicitly changed in the child style. When upgrading the Flexile style you will only overwrite the parent such that customizations in the child are preserved; when the parent is upgraded that style is overwritten by the new version of the style and everything is inherited by the child except for the header template which is customized in the child.
    Apocalypse and Dodgeboard like this.
  6. Ryan Kent

    Ryan Kent Well-Known Member

    I felt I understood most of what was shared in this thread but then I ran into an issue. After I completed my upgrades I realized that:

    1. My extra.css template was wiped. To the best of my knowledge it shouldn't have been touched during the upgrade process.

    2. I had a few custom templates such as the three cta_xxxx templates used to support the RSS news feed that Brogan shared. They are all gone now.

    It was my understanding that an upgrade wouldn't affect custom templates in any way. All mine are gone. I am sure I didn't just delete them nor click on them and choose "revert template" which ends up deleting them. Any ideas as to what could have happened to cause these templates to disappear/wipe?
  7. Brogan

    Brogan XenForo Moderator Staff Member

    EXTRA.css is never touched during an upgrade - mine has remained unaffected right from Beta 1.
    Same goes for my custom templates.

    Did you perhaps reimport a style and overwrite those templates?
  8. George

    George Active Member

    Even if I overwrite it should leave the templates that are unrelated to the style I am updating. When you update a style it removes any custom templates.
  9. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, I'm just trying to see if any other steps were carried out as a typical upgrade doesn't affect the templates in the way that has been described.

    What is the style structure with regards to parents, children, etc?
  10. Ryan Kent

    Ryan Kent Well-Known Member

    Ouch! Shortly after upgrading to XF 1.0.0 I had to update my Flexile style to 1.0. I thought "overwrite existing style" meant overwrite the matching templates, not drop the current style and re-import.

    Hard lesson to learn. Ok, so to avoid this issue in the future, I will perform all my changes and template adds into a child of Flexile. Will that avoid this problem in the future? assuming I never update the child?
  11. Ryan Kent

    Ryan Kent Well-Known Member

    I just finished cleanup of all my templates. Another question has arisen.

    My hierarchy is Default > Flexile > Flexile Blue

    If I am using a Flexile Blue template, and I choose Revert Template, what will the template revert to? The Flexile template? or the Default template?
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The Flexile template.

Share This Page