-----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
> <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-----