1. Приветствуем Вас на неофициальном форуме технической поддержки XenForo на русском языке. XenForo - коммерческий форумный движок от бывших создателей vBulletin, написанный на PHP.

1.2.0 Изменение и сравнение шаблонов

Тема в разделе "Новости XenForo", создана пользователем Romchik®, 12.04.2013.

Загрузка
  1. Romchik®

    Romchik® The Power of Dreams Команда форума

    Регистрация:
    26.09.10
    Сообщения:
    5 746
    Симпатии:
    5 311
    Версия XF:
    1.5.18
    Перевод потом.

    Anyone who has developed add-ons for XenForo 1.1 knows that template hooks are a pain. They're a pain for us too, to say the least. Plenty of people have installed the Template Modification System add-on. We've been planning a TMS-like system for some time, before the XenForo add-on was ever actually released.

    XenForo 1.2 will deprecate the template hook system and introduce it's own template modification system to make it easier for add-on developers to change templates. Note that I'm primarily focused on add-on developers here. It is possible to create your own custom template modifications if you're not an add-on developer, but unless you have multiple styles, I'd recommend just making the changes to the templates directly.

    Let's look at what a template modification is:

    ss-2013-04-12_11-35-58.png

    It's simply a "find this" and "replace with that" style replacement. You can do this to any template. If your find matches multiple times in a single template, it will replace each occurrence.

    Applying a template modification does not actually modify the template, so it will not show up as customized and it will be automatically reapplied (if possible) when upgrading.

    For those of you that want technical details, the modifications are applied before a template is parsed. If the modifications cause a template compilation error, they are automatically disabled.

    Here's what the template modification overview looks like:

    ss-2013-04-12_11-41-07.png

    All of the template modifications will be listed here, grouped by add-on and ordered by template. The checkbox enables/disables the modification. Note that if the modification is part of an add-on (and you're not in debug mode), you will not be able to edit the modification here but you can enable/disable it. More about this when editing a template.

    The 3 numbers indicate the number of times the modification matched (green), the number of times the modification failed to match (grey) and the number of times the modification caused an error (red).

    Editing a Template
    There are a few new bits when editing a template as well.

    ss-2013-04-12_11-43-10.png

    There are 3 new things here:
    • The "prevent" checkbox. If selected, modifications will be never be applied to this template. This can be used to quickly check a template without modifications or to adjust the modifications manually.
    • The "view template modifications" link. I'll discuss this below.
    • The "view custom changes" link. This will simply display a comparison of the parent version of the template (probably the master version) and the current version so you can identify the differences.
    When you select view template modifications, you'll see an overlay like this:

    ss-2013-04-12_11-43-25.png

    This shows you a comparison of how the template modifications will be applied to this template.
    If you choose to manually apply modifications, the template modifications will be "materialized" into the template - they will actually be written into the template and automatic application of modifications will be disabled in this template. You can then manually edit the modifications if you wish. (Obviously if you upgrade an add-on and they've changed their modifications or you install a new add-on that changes this template, you won't be getting those new modifications so this should be used with care.)

    Admin and Email Templates
    These aren't left out. Add-on developers will have access to very similar systems that allow the admin and email templates to be manipulated in the same way.
    We look forward to more dynamic add-ons with XenForo 1.2. :)
     
  2. Pepelac

    Pepelac Продам луц в бутылках

    Регистрация:
    28.09.10
    Сообщения:
    1 794
    Симпатии:
    1 361
    Мдя...
     
  3. Yoskaldyr

    Yoskaldyr Пользователь

    Регистрация:
    27.09.10
    Сообщения:
    1 921
    Симпатии:
    1 163
    Версия XF:
    1.0.4
    YESSSS

    Хотя представляю ад по переписыванию существующих хаков
     
  4. nmn

    nmn Активный пользователь

    Регистрация:
    11.04.13
    Сообщения:
    163
    Симпатии:
    70
    Версия XF:
    1.1.3
    Хаки на основе TMS можно и автоматически обновить, ничего ведь не поменялось. Я даже хотел править имеющийся хак, т.к. мне очень хотелось править им шаблоны админки, при всей опасности этого. Теперь не надо, и это прекрасно.

    А вот слияние пользователей сломает примерно 100% хаков с новым контентом, так что после выхода ещё месяца три придется подождать.

    И хотелось бы знать, как они решат проблему с удалением форумов, когда остаются осиротевшие темы. Обещали, вроде бы, к этой версии сделать обобщенное решение.
     
  5. Romchik®

    Romchik® The Power of Dreams Команда форума

    Регистрация:
    26.09.10
    Сообщения:
    5 746
    Симпатии:
    5 311
    Версия XF:
    1.5.18
    В 1.2 сделали ведь уже. Одно только плохо. Если раньше были удалены разделы или категории, то темы/сообщения даже после обновления не удалятся.
     
  6. devil0704

    devil0704 Местный

    Регистрация:
    23.05.11
    Сообщения:
    88
    Симпатии:
    16
    Версия XF:
    1.1.4
    Romchik®, я правильно понимаю? Разработчики решили взять самые популярные модификации и добавить их в движок по умолчанию?
     
  7. nmn

    nmn Активный пользователь

    Регистрация:
    11.04.13
    Сообщения:
    163
    Симпатии:
    70
    Версия XF:
    1.1.3
    Меня это больше с точки зрения разработчика интересует. Эта задача просто сложнее, чем кажется - чтобы удалить раздел форума с, допустим, тысячью тем в нём, необходимо сделать это через DataWriter с загрузкой каждой темы по отдельности, иначе не отработают методы *Delete и база превратится в мусорный полигон. Так что мне хотелось бы видеть что-то типа DW, но для работы сразу с множеством записей. Но разработчики, я думаю, найдут способ меня неприятно удивить.

    Кстати, с изменением шаблонов ещё одна опасность - не факт, что правки можно будет просто глобально отключить без перестроения кэшей, т.к. сейчас загрузчик шаблонов не умеет их перекомпилировать при необходимости. В результате даже отключение всех хаков через config.php убитый ими форум не оживит.
     
  8. CyberAP

    CyberAP Местный

    Регистрация:
    05.10.10
    Сообщения:
    2 604
    Симпатии:
    1 660
    Версия XF:
    1.5.10
    Так и не понял почему не добавили экспорт TM вместе со стилем. В какой раз уже игнорируют создателей стилей, а их ведь немало уже.

    Кстати не разобрался, позволяет ли этот аддон модифицировать сам движок XF? К примеру если хочется парсить настройки стиля по-другому.
     
  9. infis

    infis Местный

    Регистрация:
    27.06.11
    Сообщения:
    5 966
    Симпатии:
    3 548
    Версия XF:
    1.5.9
    Все изменения как раз можно легко отключить. Для этого там есть специальный чек-бокс.
    Как я понимаю, в этом случае просто загрузится оригинальный шаблон. Будет ли он заново компилироваться или будет постоянно храниться его скомпилированная версия - неизвестно.
     
  10. aligon7

    aligon7 Местный

    Регистрация:
    22.12.12
    Сообщения:
    997
    Симпатии:
    66
    Версия XF:
    1.4.7
    нужна полная инструкция, как им пользоваться. Стоит 1.2
     

Поделиться этой страницей