javascript - Extend template for js inclusion -


i have web project. project based on smarty templates. have base.tpl common structure, pages of site.

the base.tpl have next line, thats includes template requested user:

{include file="{$request}"} 

for example. when user request http://mydomain/contact, $request have "contact.tpl" value.

and bottom of base template have inclusion of commons js files:

{block name="javascript"}     <script src="{$base_url}/assets/js/libs/jquery-1.10.2.min.js"></script>     <script src="{$base_url}/assets/bootstrap/js/bootstrap.min.js"></script>     <script src="{$base_url}/assets/js/common.js"></script> {/block} 

so, templates requested user, requires inclusion of mores javascript files, insert in "javascript" block.

i try, example in contact.tpl next code:

{block name="javascript" prepend}     <script src="{$base_url}/assets/js/libs/validation/jquery.validate.js"></script>     <script src="{$base_url}/assets/js/libs/validation/localization/messages_es.js"></script>     <script src="{$base_url}/assets/js/contact.js"></script> {/block} 

but, files not load in browser. ideas ?.

that's not how works, blocks not processed including file. should like:

base.tpl:

<html>   <head> {block name="javascript"}     <script src="{$base_url}/assets/js/libs/jquery-1.10.2.min.js"></script>     <script src="{$base_url}/assets/bootstrap/js/bootstrap.min.js"></script>     <script src="{$base_url}/assets/js/common.js"></script> {/block}   </head>   <body>   {block name="contents"}{/block}   </body> </html> 

contact.tpl:

{extends file="base.tpl"}  {block name="javascript" prepend}     <script src="{$base_url}/assets/js/libs/validation/jquery.validate.js"></script>     <script src="{$base_url}/assets/js/libs/validation/localization/messages_es.js"></script>     <script src="{$base_url}/assets/js/contact.js"></script> {/block} {block name="contents"} contact form here {/block} 

check smarty's template inheritance more information


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -