setCustomTemplate() + block cache

Permalink 13 12 Browser Info Environment
In a lot of blocks we set custom templates directly on the area for specific block types. Like in the example below here:

$a = new Area( 'Hoofdbeeld' );
$a->setCustomTemplate( 'image', 'templates/bloemist4_hoofdbeeld.php' );
$a->setCustomTemplate( 'slideshow', 'templates/bloemist4_hoofdbeeld.php' );
$a->display($c);

Basically the image and slideshow templates perform an image resize/crop before actually showing the image. So when you add an image or slideshow block, you don't have to worry about image sizes.

At first when you add the block in edit mode, the custom template is not applied immediately. Only after you exit edit mode, the custom template will be applied.

This isn't a really big problem, until you enable the block cache. When the block cache is enabled, the initial view (in edit mode), so without the custom template applied will be cached.

Now when you exit edit mode, the (incorrect) cached output will be shown. So basically this renders the setCustomTemplate() useless until the cache expires.


Status: Postponed
revenew
mkly replied on at Permalink Reply
mkly
Hello,
When you say "In Edit Mode", do you mean only when the red dashes are around the blocks or just when someone is logged in with Edit permissions?

Best Wishes,
Mike
revenew replied on at Permalink Reply
revenew
I have created some screenshots, so you can see exactly what is going on:

http://c5.s01.revenew.nl/

Basically what you see is: when you add content (image in this example) at first when it's just been added (in edit mode), it renders using the default view (so the custom template is being ignored).

At this moment (step 4 in the screenshots) the block cache is being created ignoring the custom view.

Every view after this will show the cached version, that was rendered without the custom view. Until the block cache is cleared. Then it will re-render the block with the correct custom view.

If the block cache is disabled. The same thing will happen when you add content -> it will ignore the custom view right after adding.

But then when you exit the edit mode (publish changes), the custom view will be applied -> there is no cache so it renders with the custom template, just like what happens when you clear the cache.
revenew replied on at Permalink Reply
revenew
The nicest solution would be that the custom view would be applied on the first render (in edit mode, when you just added the content).

May be an easier solution would be to disable the caching of the block when you're in edit mode.
JohntheFish replied on at Permalink Reply
JohntheFish
Andrew and Frz committed on Totally Random a few weeks ago that block-by-block selective control of the block cache would be added for 5.7 and probably for 5.6.3 if that happens before 5.7.
dbaggs replied on at Permalink Reply
dbaggs
I agree with this suggested approach. The area knows about what custom templates to apply to certain blocks within the area at the time the block is added.

Therefore, specifically bypassing this information is the bug in my opinion. Reading this info on the area and rendering with the right template straight off would resolve this.

The Block-by-block approach doesn't really appear to address the core issue and would seem more effort to implement. Of course I haven't the understanding of what other issues that solution may address so this is just my opinion.
JohntheFish replied on at Permalink Reply
JohntheFish
My concern at this stage is that there is so far to go in 5.7 user interface development that basic functional issues like the over-enthusiastic block cache (of which this issue is just one symptom), get forgotten because core team effort is so focussed on the new interface.
dbaggs replied on at Permalink Reply
dbaggs
Perhaps. If I get time, I'll do a little digging myself and perhaps submit a code fix suggestion.
dbaggs replied on at Permalink Reply
dbaggs
This has bugged me for some time too so I'm glad its been reported.

In a similar way to what's already been described, I add a custom template in code and this is cached once edit mode has been exited (and even logged out).

concrete5 Environment Information

# Concrete5 Versie
5.6.2

# Concrete5 Extensies
Aviary Image Editor (1.2), Debtor Sites (1.1.1).

# Concrete5 Overschrijvingen
blocks/content, blocks/events, blocks/order, blocks/shoppingcart, blocks/news, blocks/footnote3, blocks/bloempleinmenu, blocks/form, blocks/tips, blocks/faq, blocks/footnote1, blocks/occasion, blocks/image, blocks/footnote2, blocks/garanties, blocks/teaser, blocks/article, blocks/slideshow, blocks/productteaser, blocks/home_occasion, controllers/extras.php, controllers/inloggen.php, controllers/zoek-een-bloemist.php, controllers/registratiecontract.php, controllers/dashboard, controllers/aanmelden.php, controllers/account.php, controllers/artikel.php, controllers/bestel.php, controllers/gelegenheid.php, controllers/bestel, controllers/bestellen-buitenland.php, controllers/registreer.php, controllers/sso.php, controllers/zoeken.php, controllers/oci.php, controllers/page_types, controllers/ssodebtor.php, elements/debtors, elements/orders, elements/header_required.php, elements/block_area_add_new.php, elements/article_image.php, elements/landen.php, elements/members, elements/subarticle_image.php, helpers/concrete, helpers/color.php, helpers/navigation.php, jobs/newsletter_image_export.php, jobs/fo_import_mssql_debtors.php, jobs/create_local_pages.php, jobs/bp_debtor_custom.php, jobs/bp_import_newsitems.php, jobs/fo_import_mssql.php, jobs/bp_session_cleanup.php, jobs/bp_cleanup.php, jobs/order_pending.php, jobs/newsletter_users_export.php, jobs/fo_import_images.php, jobs/geocode.php, jobs/fo_import_changes.php, js/colorpicker.js, js/cufon-yui.js, js/general.js, css/shoppingcart.css, css/orderprocess.css, css/colorpicker.css, libraries/afterpay.php, libraries/import.php, libraries/dispatcher.php, libraries/member.php, libraries/session.php, libraries/controller.php, libraries/rgb, mail/order_confirmation.php, mail/order_offline_member.php, models/stack, models/bp_member_profile.php, models/bp_member_profiles.php, models/bp_faq.php, models/fo_article_color.php, models/bp_newsitems.php, models/shoppingcart.php, models/fo_continent.php, models/fo_colors.php, models/fo_member_holidays.php, models/fo_article_occasions.php, models/fo_parameter.php, models/bp_debtor_site.php, models/fo_color.php, models/bp_home_occasions.php, models/fo_countries.php, models/pc_reeksen.php, models/fo_debtor_bloemplein_card_occasion_exclude.php, models/fo_debtor_bloemplein_status.php, models/pc_gemeentes.php, models/fo_article_colors.php, models/fo_member_occasions.php, models/fo_debtors_bloemplein.php, models/fo_debtor_bloemplein_card_debtors.php, models/bp_order_items.php, models/bp_tips.php, models/bp_order_logs.php, models/user.php, models/voucher.php, models/fo_member_holiday.php, models/bp_tip.php, models/bp_debtor_customfield.php, models/fo_debtor_addresses.php, models/bp_sessions.php, models/pc_reeks.php, models/fo_debtor_bloemplein.php, models/fo_debtor_bloemplein_customfields.php, models/bp_log.php, models/fo_member_occasion.php, models/fo_article_sub_articles.php, models/fo_article_sub_article.php, models/pc_straten.php, models/bp_newsitem.php, models/bp_site_domain.php, models/fo_parameters.php, models/bp_order.php, models/bp_faqs.php, models/bp_productteaser.php, models/fo_debtor_contact.php, models/pc_gemeente.php, models/fo_bloemplein_subscriptions.php, models/vouchers_used.php, models/fo_articles.php, models/bp_orders.php, models/fo_debtor_contacts.php, models/shoppingcart_item.php, models/fo_occasions.php, models/fo_bloemplein_subscription.php, models/bp_session.php, models/fo_members.php, models/bp_member_users.php, models/fo_article_type.php, models/fo_occasion_types.php, models/bp_order_item.php, models/bp_debtor_profile.php, models/pc_plaatsen.php, models/pc_plaats.php, models/fo_debtor.php, models/fo_article_sub_type.php, models/fo_debtor_bloemplein_card_debtor.php, models/file_set.php, models/fo_article_occasion.php, models/fo_member.php, models/bp_order_log.php, models/fo_debtor_bloemplein_customfield.php, models/fo_article_sub_types.php, models/bp_logs.php, models/pc_straat.php, models/bp_member_domain.php, models/fo_member_occasion_debtor_exclude.php, models/bp_site_domains.php, models/vouchers.php, models/fo_debtor_address.php, models/bp_home_occasion.php, models/bp_oci.php, models/bp_debtor_sites.php, models/fo_debtor_bloemplein_card.php, models/bp_aanmeldingen.php, models/bp_footnote.php, models/fo_debtor_bloemplein_statuses.php, models/bp_debtor_customfields.php, models/bp_footnotes.php, models/fo_debtors.php, models/bp_productteasers.php, models/voucher_used.php, models/bp_ocis.php, models/bp_event.php, models/fo_article.php, models/page_list.php, models/page_delete.php, models/fo_occasion.php, models/bp_aanmelding.php, models/fo_debtor_bloemplein_cards.php, models/bp_member_domains.php, models/bp_debtor_profiles.php, models/fo_occasion_type.php, models/fo_country.php, models/fo_debtor_bloemplein_card_occasion_excludes.php, models/bp_member_user.php, models/fo_continents.php, models/fo_article_types.php, models/fo_member_occasion_debtor_excludes.php, models/bp_events.php, single_pages/extras.php, single_pages/page_not_found.php, single_pages/inloggen.php, single_pages/zoek-een-bloemist.php, single_pages/registratiecontract.php, single_pages/dashboard, single_pages/aanmelden.php, single_pages/account.php, single_pages/artikel.php, single_pages/algemene-voorwaarden.php, single_pages/openingstijden.php, single_pages/bestel.php, single_pages/account, single_pages/gelegenheid.php, single_pages/bestel, single_pages/bestellen-buitenland.php, single_pages/bestellen-buitenland-artikelen.php, single_pages/bloemisten.php, single_pages/contact.php, single_pages/bloemen.php, single_pages/registreer.php, single_pages/sso.php, single_pages/over.php, single_pages/zoeken.php, single_pages/leden.php, single_pages/oci.php, single_pages/ssodebtor.php, themes/fleurop_kerst, themes/condoleanceregister, themes/bloemplein_bloemisten_1, themes/bloemplein_bloemisten_4, themes/bloemplein_portal, themes/bloemplein_bloemisten_5, themes/bloemplein_bloemisten_3, themes/fleurop_valentijn, tools/checkmember.php, tools/fixpermissions.php, tools/shoppingcart.php, tools/bloemplein.php, tools/shoppingcart, tools/huisstijl.php, tools/repairthemes.php, tools/valentijn_order_fix.php, tools/mp_other.php, tools/members_by_city.php, tools/dp.php, tools/repair_site.php, tools/man_complete_order.php, tools/home_occasion.php, tools/mailtest.php, tools/urls_to_fleurop.php, tools/check_debtor_username.php, tools/controle.php, tools/set_page_attribs.php, tools/address.php, tools/dsearch.php, tools/logo.php, tools/add_single_page.php, tools/getimage.php, tools/servicetest.php, tools/productteaser.php, tools/fix-extras.php, tools/pages, tools/sitemap.php

# Server Software
Apache/2.2.16 (Debian)

# Server API
apache2handler

# PHP Versie
5.3.14

# PHP Extensies
apache2handler, apc, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imagick, imap, intl, ionCube Loader, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mssql, mysql, mysqli, oci8, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_OCI, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, SQLite, sqlite3, ssh2, standard, sysvmsg, sysvsem, sysvshm, thrift_protocol, tidy, tokenizer, uploadprogress, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Code Tracing, Zend Data Cache, Zend Debugger, Zend Download Server, Zend Job Queue, Zend Optimizer+, Zend Page Cache, Zend Session Clustering, Zend Utils, zip, zlib.

# PHP Instellingen
max_execution_time - 60
log_errors_max_len - 8192
max_file_uploads - 50
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 256M
post_max_size - 256M
safe_mode - Off
safe_mode_exec_dir - <i>no value</i>
safe_mode_gid - Off
safe_mode_include_dir - <i>no value</i>
sql.safe_mode - Off
upload_max_filesize - 256M
ldap.max_links - Unlimited
memcache.max_failover_attempts - 20
mssql.max_links - Unlimited
mssql.max_persistent - Unlimited
mssql.max_procs - Unlimited
mssql.textlimit - Server default
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
oci8.max_persistent - -1
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
safe_mode_allowed_env_vars - PHP_
safe_mode_protected_env_vars - LD_LIBRARY_PATH
zend_codetracing.max_concurrent_trace_buffers - 5
zend_codetracing.max_depth - 2
zend_codetracing.max_elements - 10
zend_codetracing.max_freq - 1
zend_codetracing.max_string - 48
zend_debugger.max_msg_size - 2097152
zend_debugger.tunnel_max_port - 65535
zend_optimizerplus.max_accelerated_files - 2000
zend_optimizerplus.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36