Display additional information in a collection view

228 views
Skip to first unread message

Jon Whipple

unread,
Feb 4, 2015, 10:56:37 PM2/4/15
to isla...@googlegroups.com
Apologies if this appears twice. Google says I posted the first attempt, but there is no sign of it…

Hi all,

I'm designing new displays for Islandora collections. Context dictates I have to accomplish my work in a Drupal theme. I am successfully intercepting and overriding Islandora and solution pack HTML, CSS (and presumably, Javascript -though I haven't tested the .js yet). My theme is located in the Drupal install at /html/sites/all/themes as is customary Drupal practice.

My goal is to display data to repository users as shown in this wireframe (this example is the grid display but list display will show same data):

As I click through the pages of the sample data in the development installation I am working in, I can see the system has the information I would like to display, it's just displayed in different places.

Is there a simple way to use a php snippet (such as <?php print something($something['blabbity']); ?>) to get and insert the following:

1. Date of last update to collection / Date of creation of the newest object in the collection / Date of the latest revision to an object in the collection

2. The number of items within a collection. This also means the number of collections contained within this collection and or the number of objects within this collection

3. The file size of an object (in kilobytes, megabytes, or other meaningful measure so a user knows what they're getting into if they choose to download a file )

4. The file type of an object (.pdf, .txt, .jpg, .tif, xls, doc etc.)

Right now, I am overriding islandora-basic-collection.tpl.php by including a file of the same name in my theme. This works as expected.

Here's my template, slightly modified from the original to make some regions for me to display this information:

<?php
/**
 * @file
 * islandora-basic-collection.tpl.php
 *
 * @TODO: needs documentation about file and variables
 */

?>


<div class="islandora islandora-basic-collection">
 
<div class="islandora-basic-collection-grid clearfix">
 
<?php foreach($associated_objects_array as $key => $value): ?>
    <div class="islandora-basic-collection-object
<?php print $value['class']; ?>">
       
<div class="r-collection-object-display">
         
<!-- Display title and other info as required -->
         
<div class="islandora-basic-collection-caption"><?php print filter_xss($value['title_link']); ?></div>
       
</div>
       
<div class="r-collection-object-data">
         
<div class="r-updated">last mod date<?php print filter_xss($value['created_date']); ?></div>
         
<div class="r-item-count">number of items in collection</div>
       
</div>
   
</div>
 
<?php endforeach; ?>
</div>

Based on line 16
<div class="islandora-basic-collection-caption"><?php print filter_xss($value['title_link']); ?></div>

I thought perhaps to simply restate it like:

<?php print filter_xss($value['created_date']); ?>


but that fails. The objects are rendered to the screen but I get this error for every object: 

Notice: Undefined index: created_date in include() (line 19 of /var/www/drupal-7.34/sites/all/themes/radar/islandora-basic-collection-grid.tpl.php)

If there's no pre-made way to call for this information from the system, how would I find out what is available, and further, what is the specific way to "roll my own"?

I'm not a programmer, but I'm not scared of code and am generally familiar with how Drupal works.

Drupal 7.34
islandora
islandora_solution_pack_audio-7.x-1.3
islandora_solution_pack_collection-7.x-1.3
islandora_solution_pack_image-7.x-1.3
islandora_solution_pack_pdf-7.x-1.3
islandora_solution_pack_video-7.x-1.3

TIA for any insight and help.

Jon

+

Jon Whipple CGD
Jon Whipple, Design Counsel

Professional Member of the Society of Graphic Designers of Canada

Diego Pino

unread,
Feb 5, 2015, 8:35:45 AM2/5/15
to isla...@googlegroups.com
Hi Jon, you are almost there!

Start by looking at theme/theme.inc inside islandora_solution_pack_collection, in specific this hook implementation: function template_preprocess_islandora_basic_collection
If you look close inside this function you will find all default properties and metadata passed to every object inside a the collection view theme: e.g dc metadata is made available under  $associated_objects_array[$pid]['dc_array'] (as an array too). If you need more data, the you will have to implement your own preprocess hook and add more. Not complicated at all.

Cheers

D

Jon Whipple

unread,
Feb 5, 2015, 2:40:22 PM2/5/15
to isla...@googlegroups.com
Thanks Diego. I'll be looking at this later this afternoon. I appreciate it. But when I see stuff like:

Not complicated at all.

I catch my breath.

Diego Pino

unread,
Feb 5, 2015, 4:34:43 PM2/5/15
to isla...@googlegroups.com
Hi, just ask it if gets breath-taking.

Phil Redmon

unread,
Feb 6, 2015, 10:16:46 AM2/6/15
to isla...@googlegroups.com
There are several parts to your issue:

Digital object info: Some of this customization you could use islandora's solr metadata display. That would display anything related to the object that is stored in solr.
Summary info: Number of objects in collections can be accomplished using a sparql query.
Custom theme: The look and feel of the display can be modified using a theme/subtheme.

--
For more information about using this group, please read our Listserv Guidelines: http://islandora.ca/content/welcome-islandora-listserv
---
You received this message because you are subscribed to the Google Groups "islandora" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora+...@googlegroups.com.
Visit this group at http://groups.google.com/group/islandora.
For more options, visit https://groups.google.com/d/optout.



--
phil

Jon Whipple

unread,
Feb 9, 2015, 6:36:14 PM2/9/15
to isla...@googlegroups.com
Hi Phil,

Thanks. Are solr metadata and sparql queries available to me from the theme context via a function file (theme.inc or template.php)? I need to be able to accomplish my objective strictly within the limits of standing within my theme.

Jon Whipple

unread,
Feb 22, 2015, 3:23:44 PM2/22/15
to isla...@googlegroups.com
Hi Diego, following your instructions I read the theme.inc in islandora_solution_pack_collection

I can output into my template the following from that file:
$value['pid']);
$value
['path']);
$value
['title']);
$value
['class']);
$value
['thumbnail']);
$value
['thumb_link']);

Do I need to read every theme.inc file from every module, in order to compile a list of variables that I can use? Is there not a way to ask the system what's available to me?

Also, do I use the variables the exact same way as it seems I should from the collections module, or are there different ways depending on the module and how would I find that out?
Do I always use them in this fashion:
<?php print filter_xss($value['title_link']); ?>
and what does that even mean?




On Thursday, 5 February 2015 05:35:45 UTC-8, Diego Pino wrote:

Diego Pino

unread,
Feb 23, 2015, 9:43:19 AM2/23/15
to isla...@googlegroups.com
Hi Jon,

If you got the development module enabled you can start by checking what is available by doing: 
dpm($value) inside the template. This will pretty print the content of this array. So there is no need to read every theme.inc (but it's useful anyway to see how the passed variables are handled/processed) and also to understand how theme complements, alters or adds functionality. The idea behind the preprocess hook is to enable/process additional variables for your template. So if you need additional values in your template the you will need to implement your own hook.
filter_xss is just a cleaner function. It get rids of cross site scripting code(attack!), checks for well formed html, etc. Start by checking whats inside the $values array first.

Cheers

-Diego 

Jon Whipple

unread,
Feb 23, 2015, 2:24:06 PM2/23/15
to isla...@googlegroups.com
Thanks Diego,

Not sure if I have development module available but will check. If not, I will compile a list from theme.inc files.

OK, I'm only passingly familiar with the preprocess hook idea in Drupal, but because I'm not a programmer, you may find me asking about this more.

filter_xss then is a cross-site scripting check to prevent attacks via data being passed beck and forth between various layers of the installation?

Thanks!

Jon

Diego Pino

unread,
Feb 23, 2015, 3:48:40 PM2/23/15
to isla...@googlegroups.com
Hi, no problem!
filter_xss basicly removes "all" (never sure!) possible harmful code before printing it out. So it's just a safety rule to use it when you don't have a different method of knowing the source of a particular piece of text/html/etc.

Jon Whipple

unread,
Mar 2, 2015, 4:32:32 PM3/2/15
to isla...@googlegroups.com
I need help printing values I see in the theme.inc file to my template. I don't know how to program, so I am attempting stuff by mimicking patterns I see. Of course this only goes so far.

For example, I see this is the islandora_solution_pack_collections module theme.inc:


function template_preprocess_islandora_basic_collection(&$variables) {
  $islandora_object
= $variables['islandora_object'];


 
try {
    $dc
= $islandora_object['DC']->content;
    $dc_object
= DublinCore::importFromXMLString($dc);
 
}
 
catch (Exception $e) {
    drupal_set_message
(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE);
 
}
  $page_number
= (empty($_GET['page'])) ? 0 : $_GET['page'];
  $page_size
= (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
  $results
= $variables['collection_results'];
  $total_count
= count($results);
  $variables
['islandora_dublin_core'] = isset($dc_object) ? $dc_object : array();
  $variables
['islandora_object_label'] = $islandora_object->label;
  $display
= (empty($_GET['display'])) ? 'list' : $_GET['display'];
 
if ($display == 'grid') {
    $variables
['theme_hook_suggestions'][] = 'islandora_basic_collection_grid__' . str_replace(':', '_', $islandora_object->id);
 
}
 
else {
    $variables
['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id);
 
}

This would suggest to me that I should be able to print the $total_count into my template:

<?php


/**
 * @file
 * islandora-basic-collection-grid.tpl.php

 *
 * @TODO: needs documentation about file and variables
 */

?>


 
<div class="islandora-basic-collection-grid clearfix">

 
<?php foreach($associated_objects_array as $key => $value): ?>    
    <div class="islandora-basic-collection-object
<?php print $value['class']; ?>
">
       
<div class="object-data-display">
       
<div class="islandora-basic-collection-title"><?php print filter_xss($value['title_link']); ?></div>
       
<div class="islandora-basic-collection-info">
         
<p>class <?php print filter_xss($value['class']); ?></p><!-- works -->
         
<p>title <?php print filter_xss($value['title']); ?></p><!-- works -->
         
<p>path <?php print filter_xss($value['path']); ?></p><!-- works -->
       
</div>
       
<div class="islandora-basic-collection-bottom-bar">
         
<div class="islandora-basic-collection-left-panel">isoDate</div>
         
<div class="islandora-basic-collection-right-panel">
           
<!-- How do I show $total_count here? -->
         
</div>

       
</div>
     
</div>
   
</div>
 
<?php endforeach; ?>
 
</div>

Have tried all of these (please don't laugh, I really don't know what the I'm doing) but they don't work in various ways:
<?php foreach($islandora_object): ?>
 
<?php print filter_xss($total_count[]); ?>
<?php endforeach; ?>


<?php foreach($islandora_object): ?>
 
<?php print filter_xss($total_count); ?>
<?php endforeach; ?>


<?php foreach($islandora_object): ?>
 
<?php print filter_xss($total_count[]); ?>
<?php endforeach; ?>


<?php foreach($islandora_object as $key => $value): ?>
 
<?php print filter_xss($value['total_count']); ?>
<?php endforeach; ?>


<?php foreach($islandora_object as $object): ?>
 
<?php print filter_xss($object['total_count']); ?>
<?php endforeach; ?>


<?php foreach($total_count): ?>
 
<?php print filter_xss($total_count); ?>
<?php endforeach; ?>

TIA for any guidance.

Jon (embarrassed)

Mark Jordan

unread,
Mar 2, 2015, 4:55:10 PM3/2/15
to isla...@googlegroups.com
Jon,

Haven't tested this, but in your template.php function, replace:

$total_count = count($results);

with

$variables['total_count'] = count($results);

and then in your template file, try:

<?php print filter_xss($total_count); ?>

$value['class'], etc. is defined in the enclosing foreach loop, it's not a general way of calling values passed into your template from your preprocess function.

Mark


Jon Whipple

unread,
Mar 2, 2015, 5:17:13 PM3/2/15
to isla...@googlegroups.com
Hi Mark,

Thanks for the reply! I only sort of get what you're saying. My theme doesn't have a template.php in it (yet?). The example above is part of a function in modules/islandora_solution_pack_collection-7.x-1.3/theme/theme.inc.

I am correct in understanding that if I made a template.php in my theme, I could specifically override the function from the solution_pack? If I do so, what precisely would I need to type into it in order to get the result that you outline below?

<ignorant-rumination class="simpleton designer">From my naive point of view, shouldn't all the variables, values, and functions that 'come before' me be available to me from my theme? In some more high-level/regular kind of way? It seems strange that I would have re-handle something that already exists? Why would I need a separate development module to find out what might be available? And if I did, would it tell me how to use what's available?</ignorant-rumination>

TIA Jon
...

Mark Jordan

unread,
Mar 2, 2015, 11:28:19 PM3/2/15
to isla...@googlegroups.com

Hi Jon,


Hi Mark,

Thanks for the reply! I only sort of get what you're saying. My theme doesn't have a template.php in it (yet?). The example above is part of a function in modules/islandora_solution_pack_collection-7.x-1.3/theme/theme.inc.

Yes, sorry, my answer was misleading there...

I am correct in understanding that if I made a template.php in my theme, I could specifically override the function from the solution_pack? If I do so, what precisely would I need to type into it in order to get the result that you outline below?
If your theme doesn't have a template.php file, create one. It should live in your theme's top-level directory. Within this template.php file, create a function called yourtheme_preprocess_islandora_basic_collection(&$variables) {}, where 'yourtheme' is the name of your theme. You should copy the entire contents of the template_preprocess_islandora_basic_collection() function from the islandora_solution_pack_collections's theme/theme.inc file into this new function. Once you do that, and save your template.php file, you can start modifying the code in the function to override what the function does. If one of the modifications you make to your copy of the preprocess function is to set $variables['total_count'] = $total_count; right after $total_count = count($results);,  you'll be able to access $total_count in your custom template.



<ignorant-rumination class="simpleton designer">From my naive point of view, shouldn't all the variables, values, and functions that 'come before' me be available to me from my theme?
If you do the above, and clear your cache, all the variables should be.

In some more high-level/regular kind of way? It seems strange that I would have re-handle something that already exists? Why would I need a separate development module to find out what might be available? And if I did, would it tell me how to use what's available?</ignorant-rumination>
Others on the list may be able to provide some advice on what tools to use to assist in theme overriding, but I use the Devel module's "Theme Registry", which shows all the functions and templates for themeable items. Doesn't show you what variables are available though. Install and enable the Devel module, then enable its block. Near the bottom of the Devel block you will see the  "Theme registry" link; clicking on it displays a list of all the themeable items. You'll need to click on the '(Array, 323 elements)' or whatever it says at the top of the page.

Best tip I can give you is that changes in your code won't show up unless you clear the cache (if you use Drush, 'drush cc all, otherwise Admin > Configuration> Performance > Clear all caches.

Hope this gets you further than my previous response,

Mark

Jon Whipple

unread,
Mar 3, 2015, 10:06:56 PM3/3/15
to isla...@googlegroups.com
Hi Mark, thanks for this. Will see if I can hit it this eve (tomorrow for sure).

I have a four and a half questions about this, because I'm not sure how it applies to other items that I may want to display:

1. When I make mytheme_preprocess_islandora_basic_collection(&$variables) {}, I want to copy the contents of the template_preprocess_islandora_basic_collection() but NOT it's name?

2. Will this same method apply to any variable I see in a function from islandora or its sibling modules? So for example if there's a function in islandora core's theme.inc I can override it the same way by duplicating its function into mytheme/template.php and then modifying it? As long as it contains the same code, there is no need to indicate which theme.inc I am overriding (except in my comments)?

3. Can I take it as a general rule that when I see something analogous to $total_count = count($results); like $every_thing = thing($results);I can always just make it be $variables['every_thing'] = thing($results);?

If the stuff I'd like to display is already in the pattern $variables['every_thing'] = thing($results); but doesn't work in my template, do I just copy that function into mytheme template.php so it's available to me?

I realize some of this might seem like programming of PHP 101, but hey, I gotta start someplace.

TIA. Will advise of progress or pester with more question soon.

Jon

Mark Jordan

unread,
Mar 3, 2015, 10:47:26 PM3/3/15
to isla...@googlegroups.com
Hi Jon,

Some quick responses before I head off grid for a week or so:

Hi Mark, thanks for this. Will see if I can hit it this eve (tomorrow for sure).

I have a four and a half questions about this, because I'm not sure how it applies to other items that I may want to display:

1. When I make mytheme_preprocess_islandora_basic_collection(&$variables) {}, I want to copy the contents of the template_preprocess_islandora_basic_collection() but NOT it's name?
Exactly. If you copy the function name, PHP will be very unhappy, since you're not allowed to declare the same function more than once. The idea behind copying the original theme or preprocess function's content is so you'll have something to start with that produces HTML output (or variables that get inserted into HTML output from a template) that is similar to the original. Within your own function, however, you're allowed to customize the HTML/variables.


2. Will this same method apply to any variable I see in a function from islandora or its sibling modules? So for example if there's a function in islandora core's theme.inc I can override it the same way by duplicating its function into mytheme/template.php and then modifying it? As long as it contains the same code, there is no need to indicate which theme.inc I am overriding (except in my comments)?
Generally speaking, yes. See http://www.codesidekick.com/blog/theme-override-functions-beautify-breadcrumbs-lists-and-form-elements for examples of overriding core theme functions (for breadcrumbs, lists, and textfields) in your own template.php file. Those examples are pretty consistent with what I've explained. Apress's Pro Drupal Development 7 pages 216 ff is also a good reference.

As long as module writers (of contributed and core modules) use a theme('something') function in their modules, you should be able to override the output of that function.


3. Can I take it as a general rule that when I see something analogous to $total_count = count($results); like $every_thing = thing($results);I can always just make it be $variables['every_thing'] = thing($results);?

Yes, if I understand your question. I believe that every key in the $variables associative array gets converted to its own variable of the same type (string, array, etc.) named after the key, within templates. (Sorry for PHP talk.)

If the stuff I'd like to display is already in the pattern $variables['every_thing'] = thing($results); but doesn't work in my template, do I just copy that function into mytheme template.php so it's available to me?

I don't think I understand the question. But, if a variable doesn't appear in your template in the original function, there might be something else wrong that will prevent it from displaying in your custom function. Hard to say what would be wrong without seeing all of your code.

I realize some of this might seem like programming of PHP 101, but hey, I gotta start someplace.

Less PHP than Drupal idiom. Difficult to learn but makes weird sense once you get the hang of it.

TIA. Will advise of progress or pester with more question soon.
Hope this helps. Won't be back online for a while so have fun! Maybe someone else on the list can step in to clarify/correct what I have written.

Mark

Jon Whipple

unread,
Mar 3, 2015, 11:13:50 PM3/3/15
to isla...@googlegroups.com
Thanks a lot. This sounds sensical. Have nice time off. I'll just ask questions out loud until somebody answers in order to shut me up.
...

Jon Whipple

unread,
Mar 7, 2015, 2:33:33 AM3/7/15
to isla...@googlegroups.com
Well,

After hours of trying Mark's suggestions and fruitless and confusing reading of various Drupal fora (drupal.org stackexchange etc. ) I have to come hat-in-hand and ask for more help.

I have a template.php file in my theme now. I have copied the function that I want to override from the module theme.inc file, into my template file.

I have changed the name of the function.
function radar_preprocess_islandora_basic_collection(&$variables) {

I have altered the function as Mark outlined in his answers to me in two ways:
replace: $total_count = count($results);
with 
$variables['total_count'] = count($results);
and then in your template file, try:
<?php print filter_xss($total_count); ?>

as well as 

If one of the modifications you make to your copy of the preprocess function is to set $variables['total_count'] = $total_count; right after $total_count = count($results);,  you'll be able to access $total_count in your custom template.

I get errors each time the loop hits my print command: 
• Notice: Undefined index: total_count in include() (line 24 of /var/www/drupal7.34/sites/all/themes/radar/islandora-basic-collection-grid.tpl.php).

I have installed Devel module and enabled it. I can see its output and it lists many things including a big list of functions (which are linked to drupal.org api pages and so don't show any info. Also variables listed but I'm not a programmer, so at this point I have no idea what's going on. I did not install Theme Developer Module as many posts,articles and books suggest, because it doesn't work without a particular flavour of dependency and my confidence is pretty low and I don't want to screw up my dev install without know what the heck is going on.

I have read variously:
  • a function that's defined in a module cannot be overridden in a theme's template.php and it's impossible to do so (in which case Mark's suggestion had no hope of working, and presumably the things you guys do all day don't work either)
  • that the name of the function in the template.php must match the template where it will be used (which it kind of does/n't)
  • that the word template_ must begin a function name if it's part of a module (yep, but not after I rename it in my template.php)
  • if its a module's function that can be overridden in a theme's template.php it will begin with theme_  (nope)
So, given the diagram above (which I am happy to elaborate on), what should I do to get nice useful information about the collections and their contents into the display of pages for users?

TIA

Jon

Jared Whiklo

unread,
Mar 7, 2015, 7:39:49 PM3/7/15
to isla...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jon,

I noticed that your function is
radar_preprocess_islandora_basic_collection(&$vars)

but your template is
islandora-basic-collection-grid.tpl.php

For our theme I override the grid template as well, but I use the

UofM_2_preprocess_islandora_basic_collection_grid(&$vars)

to alter it.

So I might suggest changing your function name to

radar_preprocess_islandora_basic_collection_grid(&$variables) {

Also, instead of re-writing all the code from the previous functions
you can use what they have done and just add your code in.

You want a count of the results, each of those results are stored in
the variable.

$variables['associated_objects_array']

So you can have your function as

function radar_preprocess_islandora_basic_collection_grid(&$variables) {
$count = count($variables['associated_objects_array']);
$variables['total_count'] = $count;
}

Done.

You sound like you have already prepared your template file for the
incoming variable.

Last thing...CLEAR ALL CACHES. This can drive you crazy, the hooks in
Drupal are cached for speed and you need that cleared.

Give it a try and let me know how it works for you.

cheers,
jared

On 2015-03-07 1:33 AM, Jon Whipple wrote:
> Well,
>
> After hours of trying Mark's suggestions and fruitless and
> confusing reading of various Drupal fora (drupal.org
> <http://drupal.org> stackexchange etc. ) I have to come hat-in-hand
> and ask for more help.
>
> I have a template.php file in my theme now. I have copied the
> function that I want to override from the module theme.inc file,
> into my template file.
>
> I have changed the name of the function. *function
> radar_preprocess_islandora_basic_collection(&$variables) {*…
>
> I have altered the function as Mark outlined in his answers to me
> in two ways: /replace: *$total_count = count($results);*/ /with
> *$variables['total_count'] = count($results);* and then in your
> template file, try: *<?php print filter_xss($total_count); ?>*/
>
> as well as
>
> /If one of the modifications you make to your copy of the
> preprocess function is to set *$variables['total_count'] =
> $total_count*; right after *$total_count = count($results);*,
> you'll be able to access *$total_count* in your custom template./
>
> I get errors each time the loop hits my print command: *• Notice:
> Undefined index: total_count in include() (line 24 of
> /var/www/drupal7.34/sites/all/themes/radar/islandora-basic-collection-grid.tpl.php).*
>
> I have installed Devel module and enabled it. I can see its output
> and it lists many things including a big list of functions (which
> are linked to drupal.org <http://drupal.org> api pages and so don't
> show any info. Also variables listed but I'm not a programmer, so
> at this point I have no idea what's going on. I did not install
> Theme Developer Module as many posts,articles and books suggest,
> because it doesn't work without a particular flavour of dependency
> and my confidence is pretty low and I don't want to screw up my dev
> install without know what the heck is going on.
>
> I have read variously:
>
> * a function that's defined in a module cannot be overridden in a
> theme's template.php and it's impossible to do so (in which case
> Mark's suggestion had no hope of working, and presumably the
> things you guys do all day don't work either) * that the name of
> the function in the template.php must match the template where it
> will be used (which it kind of does/n't) * that the word *template_
> *must begin a function name if it's part of a module (yep, but not
> after I rename it in my template.php) * if its a module's function
> that can be overridden in a theme's template.php it will begin with
> *theme_* (nope)
>
> So, given the diagram above (which I am happy to elaborate on),
> what should I do to get nice useful information about the
> collections and their contents into the display of pages for
> users?
>
> TIA
>
> Jon
>
>> On 3 Mar, 2015, at 20:13 , Jon Whipple <jon.w...@gmail.com
>> <mailto:jon.w...@gmail.com>> wrote:
>>
>> Thanks a lot. This sounds sensical. Have nice time off. I'll just
>> ask questions out loud until somebody answers in order to shut me
>> up.
>>
>> On Tuesday, 3 March 2015 19:47:26 UTC-8, Mark Jordan wrote:
>>
>> Hi Jon,
>>
>> Some quick responses before I head off grid for a week or so:
>> ------------------------------------------------------------------------
>>
>>
>>
Hi Mark, thanks for this. Will see if I can hit it this eve
>> (tomorrow for sure).
>>
>> I have a four and a half questions about this, because I'm not
>> sure how it applies to other items that I may want to display:
>>
>> 1. When I make
>> mytheme_preprocess_islandora_basic_collection(&$variables) {}, I
>> want to copy the /contents/ of the
>> template_preprocess_islandora_basic_collection()but */NOT/* it's
>> ------------------------------------------------------------------------
>>
>>
>>
Hi Mark,
>>
>> Thanks for the reply! I only sort of get what you're saying. My
>> theme doesn't have a template.php in it (yet?). The example above
>> is part of a function in
>> modules/islandora_solution_pack_collection-7.x-1.3/theme/theme.inc.
>>
>>
>>
>>
Yes, sorry, my answer was misleading there...
>>
>>
>> I am correct in understanding that if I made a template.php in my
>> theme, I could specifically override the function from the
>> solution_pack? If I do so, what */precisely/* would I need to
>> type into it in order to get the result that you outline below?
>>
>> If your theme doesn't have a template.php file, create one. It
>> should live in your theme's top-level directory. Within this
>> template.php file, create a function called
>> yourtheme_preprocess_islandora_basic_collection(&$variables) {},
>> where 'yourtheme' is the name of your theme. You should copy the
>> entire contents of the
>> template_preprocess_islandora_basic_collection() function from
>> the islandora_solution_pack_collections's theme/theme.inc file
>> into this new function. Once you do that, and save your
>> template.php file, you can start modifying the code in the
>> function to override what the function does. If one of the
>> modifications you make to your copy of the preprocess function is
>> to set |$variables['total_count'] =$total_count; |right after
>> $total_count = count($results);, you'll be able to access
>> $total_count in your custom template.
>>
>>
>>
>> *<ignorant-rumination class="simpleton designer">*/From my naive
>> point of view, shouldn't all the variables, values, and functions
>> that 'come before' me be available to me from my theme? /
>>
>> If you do the above, and clear your cache, all the variables
>> should be.
>>
>> /In some more high-level/regular kind of way? It seems strange
>> that I would have re-handle something that already exists? Why
>> would I need a separate development module to find out what might
>> be available? And if I did, would it tell me how to use what's
>> available?/*</ignorant-rumination>*
>>
>> Others on the list may be able to provide some advice on what
>> tools to use to assist in theme overriding, but I use the Devel
>> module's "Theme Registry", which shows all the functions and
>> templates for themeable items. Doesn't show you what variables
>> are available though. Install and enable the Devel module, then
>> enable its block. Near the bottom of the Devel block you will see
>> the "Theme registry" link; clicking on it displays a list of all
>> the themeable items. You'll need to click on the '(Array, 323
>> elements)' or whatever it says at the top of the page.
>>
>> Best tip I can give you is that changes in your code won't show
>> up unless you clear the cache (if you use Drush, 'drush cc all,
>> otherwise Admin > Configuration> Performance > Clear all caches.
>>
>> Hope this gets you further than my previous response,
>>
>> Mark
>>
>>
>>
>> TIA Jon
>>
>> On Monday, 2 March 2015 13:55:10 UTC-8, Mark Jordan wrote:
>>
>> Jon,
>>
>> Haven't tested this, but in your template.php function, replace:
>>
>> |$total_count =count($results); |
>>
>> with
>>
>> |$variables['total_count'] =count($results); |
>>
>> and then in your template file, try:
>>
>> |<?php printfilter_xss($total_count);?>|
>>
>> |$value['class']|, etc. is defined in the enclosing foreach loop,
>> it's not a general way of calling values passed into your
>> template from your preprocess function.
>>
>> Mark
>>
>> ------------------------------------------------------------------------
>>
>>
>>
I need help printing values I see in the
>> theme.inc file to my template. I don't know how to program, so I
>> am attempting stuff by mimicking patterns I see. Of course this
>> only goes so far.
>>
>> For example, I see this is the
>> islandora_solution_pack_collections module theme.inc:
>>
>> …
>> functiontemplate_preprocess_islandora_basic_collection(&$variables){
>>
>>
$islandora_object
>> =$variables['islandora_object'];
>>
>>
>> try{ $dc =$islandora_object['DC']->content; $dc_object
>> =DublinCore::importFromXMLString($dc); } catch(Exception$e){
>> drupal_set_message(t('Error retrieving object %s
>> %t',array('%s'=>$islandora_object->id,'%t'=>$e->getMessage())),'error',FALSE);
>>
>>
}
>> $page_number =(empty($_GET['page']))?0:$_GET['page']; $page_size
>> =(empty($_GET['pagesize']))?variable_get('islandora_basic_collection_page_size','10'):$_GET['pagesize'];
>>
>>
$results =$variables['collection_results'];
>> $total_count =count($results);
>>
>> $variables['islandora_dublin_core']=isset($dc_object)?$dc_object
>> :array();
>>
>> $variables['islandora_object_label']=$islandora_object->label;
>> $display =(empty($_GET['display']))?'list':$_GET['display'];
>> if($display =='grid'){
>>
>> $variables['theme_hook_suggestions'][]='islandora_basic_collection_grid__'.str_replace(':','_',$islandora_object->id);
>>
>>
}
>> else{
>>
>> $variables['theme_hook_suggestions'][]='islandora_basic_collection__'.str_replace(':','_',$islandora_object->id);
>>
>>
}
>> …
>>
>> This would suggest to me that I should be able to print the
>> $total_count into my template:
>>
>> <?php
>>
>> /** * @file * islandora-basic-collection-grid.tpl.php * * @TODO:
>> needs documentation about file and variables */ ?>
>>
>> ...
>>
>>
>> -- For more information about using this group, please read our
>> Listserv Guidelines:
>> http://islandora.ca/content/welcome-islandora-listserv --- You
>> received this message because you are subscribed to the Google
>> Groups "islandora" group. To unsubscribe from this group and stop
>> receiving emails from it, send an email to
>> islandora+...@googlegroups.com
>> <mailto:islandora+...@googlegroups.com>. Visit this group
> -- For more information about using this group, please read our
> Listserv Guidelines:
> http://islandora.ca/content/welcome-islandora-listserv --- You
> received this message because you are subscribed to the Google
> Groups "islandora" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> islandora+...@googlegroups.com
> <mailto:islandora+...@googlegroups.com>. Visit this group
- --
Jared Whiklo
jwh...@gmail.com
- --------------------------------------------------
You know you're from Winnipeg when...You are bundled up in three
sweaters, a parka, ski pants, a touque, two pairs of mittens, boots
past you knees in 3 feet of snow in a -35 (-8000 with the windchill)
blizzard, your eyelashes are frozen together, your nose is running,
your can't feel your toes, and you stop at 7-11 for a Slurpee on the
way home.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iEYEARECAAYFAlT7mk8ACgkQqhIY384dF1Zs5ACgonWMxGHyTGdyHcyZAbiP69Cb
khoAoKZZYq5Xl+Kvyrj9zubSuR08kh/H
=Ncyx
-----END PGP SIGNATURE-----

Jon Whipple

unread,
Mar 7, 2015, 7:42:42 PM3/7/15
to isla...@googlegroups.com
Thanks Jared. I'll try this all this evening. I appreciate your clue about the count as well.

Yeah, I have caches clearing on every page load as I develop the theme. Thanks!

Jon


On 7 Mar, 2015, at 16:39 , Jared Whiklo <jwh...@gmail.com> wrote:

Signed PGP part
Jared Whiklo
jwh...@gmail.com

--------------------------------------------------
You know you're from Winnipeg when...You are bundled up in three
sweaters, a parka, ski pants, a touque, two pairs of mittens, boots
past you knees in 3 feet of snow in a -35 (-8000 with the windchill)
blizzard, your eyelashes are frozen together, your nose is running,
your can't feel your toes, and you stop at 7-11 for a Slurpee on the
way home.
--
For more information about using this group, please read our Listserv Guidelines: http://islandora.ca/content/welcome-islandora-listserv
---
You received this message because you are subscribed to the Google Groups "islandora" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages