Thursday 18 August 2011 3:33:28 pm
By : Thiago Campos Viana
In this post I will show an easy way to make eZ publish communicate with javascript.
{set-block scope=global variable=cache_ttl}0{/set-block} <input type="checkbox" id="var_test" name="var_test" {if eq(ezpreference('var_test'),'true')} checked="checked"{/if}> Test <script type="text/javascript"> var prefs_url="{"/user/preferences/set/var_test"|ezurl(no)}"; {literal} $("#var_test").change(function() { $.ajax({ url: (prefs_url+"/"+$("#var_test").is(":checked")), success: function(){} }); }); {/literal} </script>
So, basically in this sample every time the user sets the checkbox value, he sets his user preference using an ajax call to the user/preferences view telling it to set the var value, so when the user reloads the page the checkbox will remain with its last state by getting the preference value using the ezpreference template operator. Simple right?
Timing: | Jan 17 2025 23:52:48 |
Script start | |
Timing: | Jan 17 2025 23:52:48 |
Module start 'layout' | |
Timing: | Jan 17 2025 23:52:48 |
Module start 'content' | |
Timing: | Jan 17 2025 23:52:48 |
Module end 'content' | |
Timing: | Jan 17 2025 23:52:48 |
Script end |
Total runtime | 0.0700 sec |
Peak memory usage | 6,144.0000 KB |
Database Queries | 42 |
Checkpoint | Start (sec) | Duration (sec) | Memory at start (KB) | Memory used (KB) |
---|---|---|---|---|
Script start | 0.0000 | 0.0055 | 589.5313 | 152.6875 |
Module start 'layout' | 0.0055 | 0.0026 | 742.2188 | 39.5313 |
Module start 'content' | 0.0081 | 0.0605 | 781.7500 | 350.3438 |
Module end 'content' | 0.0686 | 0.0014 | 1,132.0938 | 15.8594 |
Script end | 0.0699 | 1,147.9531 |
Accumulator | Duration (sec) | Duration (%) | Count | Average (sec) |
---|---|---|---|---|
Ini load | ||||
Load cache | 0.0030 | 4.3547 | 15 | 0.0002 |
Check MTime | 0.0013 | 1.8991 | 15 | 0.0001 |
Mysql Total | ||||
Database connection | 0.0008 | 1.1810 | 1 | 0.0008 |
Mysqli_queries | 0.0283 | 40.4436 | 42 | 0.0007 |
Looping result | 0.0003 | 0.3841 | 40 | 0.0000 |
Template Total | 0.0382 | 54.7 | 2 | 0.0191 |
Template load | 0.0019 | 2.7232 | 2 | 0.0010 |
Template processing | 0.0363 | 51.9236 | 2 | 0.0182 |
Template load and register function | 0.0001 | 0.1016 | 1 | 0.0001 |
states | ||||
state_id_array | 0.0005 | 0.7420 | 1 | 0.0005 |
state_identifier_array | 0.0008 | 1.1537 | 2 | 0.0004 |
Override | ||||
Cache load | 0.0015 | 2.1234 | 9 | 0.0002 |
Sytem overhead | ||||
Fetch class attribute name | 0.0014 | 2.0685 | 3 | 0.0005 |
class_abstraction | ||||
Instantiating content class attribute | 0.0000 | 0.0106 | 3 | 0.0000 |
General | ||||
dbfile | 0.0007 | 0.9679 | 10 | 0.0001 |
String conversion | 0.0000 | 0.0072 | 4 | 0.0000 |
Note: percentages do not add up to 100% because some accumulators overlap |
Usage | Requested template | Template | Template loaded | Edit | Override |
---|---|---|---|---|---|
1 | node/view/full.tpl | blog_entry/full.tpl | extension/community_design/design/suncana/override/templates/blog_entry/full.tpl | ||
2 | content/datatype/view/ezxmltext.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tpl | ||
3 | content/datatype/view/ezxmltags/paragraph.tpl | <No override> | extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tpl | ||
1 | content/datatype/view/ezxmltags/literal.tpl | <No override> | extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tpl | ||
1 | content/datatype/view/ezkeyword.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezkeyword.tpl | ||
1 | print_pagelayout.tpl | <No override> | extension/community/design/community/templates/print_pagelayout.tpl | ||
Number of times templates used: 9 Number of unique templates used: 6 |
Time used to render debug report: 0.0001 secs