Editing
Updating Cached Front-Facing Content After Gallery Edits
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Adding logic to update front-end cached content after page image edits == The site's local `cache_class` should have 2 routines defined: `refresh_content_after_image_edit($content, $filters, $json)` and `retrieve_gallery_listings_content($content, $filters, $json)`. `cache_class::retrieve_gallery_listings_content()` simply loads the gallery listings template, populates it with data, and returns the resulting markup. `cache_class::refresh_content_after_image_edit()` calls `cache_class::retrieve_gallery_listings_content()` and then executes the logic to update the front-end cached content. For example: <syntaxhighlight lang="php"> public static function refresh_content_after_image_edit ( &$content, &$filters, &$json ) { switch($content->site_section->id->value) { case comics_class::PAGE_SECTION_ID: case sketchbook_class::PAGE_SECTION_ID: case stasis_class::PAGE_SECTION_ID: cache_class::retrieve_gallery_listings_content($content, $filters, $json); cache_class::update_parent_frontend_cache($content, $filters, $json); break; } } public static function update_parent_frontend_cache( &$content, &$filters, &$json ) { if ($content instanceof image_link_class) { if ($content->parent_id->value > 0) { $parent = null; $content_type_id = $content->get_parent_content_type_id(); if ($content_type_id) { cache_class::set_content($content_type_id, $parent); if (is_object($parent) && method_exists($parent, "update_cache")) { $parent->id->value = $content->parent_id->value; $parent->read(true); $json->status->value .= $parent->update_cache(); } } } } } </syntaxhighlight>
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information