Create Custom Menu

Answered

2 Comments

  • Tal Admon
    Comment actions 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
    Comment actions 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

Please sign in to leave a comment.

Powered by Zendesk