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

Most effective way to edit templates?

Discussion in 'XenForo Questions and Support' started by Zak Smith, May 6, 2011.

  1. Zak Smith

    Zak Smith Member

    I noted in one of the FAQs or somewhere that all the template data is stored in the database, not files on the disk. So, the natural way to edit them is through the template editing system in the admin control panel.

    The problem with this is twofold:

    1. it's a relatively slow process to (compared to running an editor on my server), and

    2. it uses the html "form" editor, which is fine for posts but not a programmer's editor by any means.

    I write code for a living and trying to do anything other than trivial edits in the form editor is just scary.

    My question-- is there an effective way to edit templates without using the template editing system in the admin control panel, given that I have access to the machine, mysql, etc.

    Ideally, I'd like a flow something like this:

    1. extract template by id/name from the database with a script, e.g. xf-checkout -t template2 member_view > tmp_member_view.txt

    2. emacs tmp_member_view.txt

    3. re-insert modified code into the database with a script, e.g. xf-checkin -t template 2 member_view < tmp_member_view.txt

    I could probably reverse engineer enough to make it work, but I'd rather leverage a solution that is known to work.

    thanks
    Zak
     
  2. Forsaken

    Forsaken Well-Known Member

  3. Zak Smith

    Zak Smith Member

    I installed the cadaver package (command line WebDAV client) on my local linux box, made the mods, and wrote these two complementary scripts per my first post. They don't have error checking, but they work provided the login details are in ~/.netrc Also note that the template number is hard coded. But you get the idea.

    xf-checkin
    Code:
    #!/bin/sh
    (
    echo cd Public_Templates
    echo cd 2
    echo put $1
    ) | cadaver http://thunderbeastarms.com/forum11/admindav.php 
    
    xf-checkout
    Code:
    #!/bin/sh
    (
    echo cd Public_Templates
    echo cd 2
    echo get $1
    ) | cadaver http://thunderbeastarms.com/forum11/admindav.php 
    
    So I can do
    Code:
    $ xf-checkout logo_block
    $ emacs -nw logo_block 
    $ xf-checkin logo_block
    
    Hit reload, and the changes show up.

    Thanks for the pointer! This works great.
     
    Mike Tougeron and Sniper like this.

Share This Page