Skip to content

v4+Minuto a minuto article type

Intro

This type of article has a special feature that makes adding and saving content simpler.

  • Add a template in configuration
  • The html template name can be mam.html.twig or mam_somename.html.twig (it should start with mam_).
  • The dropdown button that had the options to verify, publish or future publish is now a simple button that can be clicked once to interact and does the following tasks:
    • the content is automatically published;
    • the content is automatically cloned;
    • after the content is cloned a new composite module will be added automatically on top of the one published so that the user can continue adding content.

Important: The template must contain a composite module with role "content". An error will be thrown if the role "content" is not present.

html
      <div wf-module="wfed/composite/module"
           wf-role="content"
           wf-new
           wf-toolbar-position="top"
           wf-allow="+-"
      >
          <time wf-module="wfed/body_text/module"
                wf-role="time"
                wf-new
          >HH:mm</time>
          <p wf-module="wfed/body_text/module"
             wf-role="paragraph"
             wf-new           
          ></p> 
      </div>

Refreshing on public

wf-cms-base-bundle/Resources/public/javascipts/mam.js should be added in layout.

html
{% block javascripts %}
    {{ parent() }}

    {% javascripts filter="?yui_js"
        '@WfCmsBaseBundle/Resources/public/javascripts/mam.js'
        output='js/mam.js'
    %}
        <script src="{{ cdnjs }}{{ asset_url }}" type="text/javascript"></script>
    {% endjavascripts %}
{% endblock  %}

The script will search for all containers that have an attribute named data-mam-slug and will make a POST request to the url (/page/article-slug.html) specific for that container. The following will be performed:

  • it will retrieve the content and it will check if the content is not the same with cache;
  • it will replace the container content with the received content;
  • it will cache the content in memory if not present or not the same.

The request is wrapped in an interval function that receives the interval time from the attribute data-mam-refresh that can be set in article in a twig macro function (@WfCmsBase/Article/macro/mam_macro.html.twig) and in boards with the help of wf-bind="mam"

   <div wf-bind="mam"></div> // refresh time defaults to 60
   <div wf-bind="mam:120"></div> // set refresh time