...slogans are forgotten like fairy-tales were
Blog » The gallery title in a custom NextGEN Gallery template
When using custom album and gallery templates, NextGEN Gallery plugin doesn't provide any variables with the gallery name to the gallery template:
My album and gallery templates are in "wp-content/ngg/modules/photocrati-nextgen_basic_album/templates/extended.php" and "wp-content/ngg/modules/photocrati-nextgen_basic_gallery/templates/thumbnails/index.php" respectively.
I've found only one datum which can lead to the current gallery title. It's gallery ID accessable by $displayed_gallery->container_ids from a gallery template. In my opinion, the best way of fetching the gallery title is to issue an SQL-query using one of the plugin's DAO. Data Access Objects are called DataMappers here, so we need a C_Gallery_Mapper:
$mapper = C_Gallery_Mapper::get_instance(); $gid = $displayed_gallery->container_ids; $rows = $mapper->select()->where('gid = ' . $gid)->limit(1)->run_query(); $title = $rows->title;
It's important to get data using the above SQL-query, because NextGEN Gallery uses exactly the same SQL-query further. Thus the plugin caches results of querying the database, the results of our SQL-query will be used by the plugin a little bit later (checked through MySQL general log).