Quantcast
Viewing all articles
Browse latest Browse all 292550

Use Twig templates for main help topic pages of modules

Problem

  • String concatenation madness in hook_help():
    <?php
          $output
    .= '<h3>'. t('Uses') . '</h3>';
         
    $output .= '<dl>';
         
    $output .= '<dt>'. t('Creating aliases') . '</dt>';
         
    $output .= '<dd>'. t('Users with sufficient <a href="@permissions">permissions</a> can create aliases under the <em>URL settings</em> section when they create or edit content. Some examples of aliases are: ', array('@permissions'=> url('admin/people/permissions', array('fragment'=> 'module-path'))));
         
    $output .= '<ul><li>'. t('<em>member/jane-smith</em> aliased to internal path <em>user/123</em>') . '</li>';
         
    $output .= '<li>'. t('<em>about-us/team</em> aliased to internal path <em>node/456</em>') . '</li>';
         
    $output .= '</ul></dd>';
         
    $output .= '<dt>'. t('Managing aliases') . '</dt>';
         
    $output .= '<dd>'. t('The Path module provides a way to search and view a <a href="@aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array('@aliases'=> url('admin/config/search/path'))) . '</dd>';
         
    $output .= '</dl>';
    ?>

Goal

  • Sanity?

    <h3>Uses</h3>

    <dl>
    <dt>Creating aliases</dt>
    <dd>Users with sufficient <a href="{{ 'admin/people/permissions#module-path'|url }}">permissions</a> can create aliases under the <em>URL settings</em> section when they create or edit content. Some examples of aliases are:
    <ul>
    <li><em>member/jane-smith</em> aliased to internal path <em>user/123</em></li>
    <li><em>about-us/team</em> aliased to internal path <em>node/456</em></li>
    </ul>
    </dd>
    <dt>Managing aliases</dt>
    <dd>The Path module provides a way to search and view a <a href="{{ 'admin/config/search/path'|url }}">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.</dd>
    </dl>

    (sorry, I'm not up to speed with twig template syntax)

Details

  • Obviously, a couple of things to figure out...
    1. Extracting (static) translatable strings out of twig templates.
    2. Making that |url filter work.
    3. ...more...

Viewing all articles
Browse latest Browse all 292550

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>