Create Custom Menu

Respondida

2 Comentários

  • Tal Admon
    Ações de comentário Permalink

    Hi Sam,

    There is a way to reuse code in several template pages like so:

    Say I have an html code I want to reuse:

    First, I will minify it and put it in a jQuery html clause:
    jQuery('#mycode').html('........');

    Save this file as mycode.js and upload it as an asset to your template.

    Now, in any page you want to reuse this code, add the following lines to your template:

    <div id="mycode"></div>
    <script src="{{asset 'mycode.js'}}"></script>

    The first line will add an empty <div> section with an id "mycode".
    The second one will get the script we compiled to execute.

    The script itself is looking for that "mycode" div element and adding the html we wrote in it.

    To minify the html, you can simply use online tools like: http://www.willpeavy.com/minifier/

    Let me know if you this works out.

    --Tal

    0
  • Sam
    Ações de comentário Permalink

    Thanks Tal. I could use some JS, yes. Great suggestion.

    I wonder if there is another more vanilla way to create an include and add it to the necessary templates.

    0

Por favor, entrar para comentar.

Powered by Zendesk