Author Topic: PHP Code for getting Gallery image count from within sobi2.details.tmpl.php  (Read 14707 times)

0 Members and 1 Guest are viewing this topic.

Offline aboututila

I would like to be able to add PHP code in sobi2.details.tmpl.php to test the number of Gallery images for the listing currently being displayed, or as a minimum to test that the number of Gallery images for this listing is not NULL.

ie: if (number of gallery images for this listing) > some number
     do something ....

or

if the actual count cannot be obtained
    if (number of gallery images for this listing)==!NULL
    do something ....

Any ideas?

Thanks - Mark
Country: Honduras Honduras |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline aboututila

OK, I finally managed to work it out myself.

Here is the code;

if (method_exists($this->plugins['gallery'],'countImages'))
   {$GalleryImageCnt = $this->plugins['gallery']->countImages($sobi2Id);
   echo "The Number of Images in the Gallery Plug-in for this listing = ".$GalleryImageCnt."<br />\n";
   }
else
   echo "The Gallery Plug-in is not installed (or the gallery countImages Method/Function does not exist)";

Note : The code example I have given above, only works in sobi2.details.tmpl.php
It does not work in sobi2.vc.tmpl.php

Regards - Mark
« Last Edit: 24. August 2007, 18:08:12 by aboututila »
Country: Honduras Honduras |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline ~GW~

  • Sobi Experte
  • ****
  • Posts: 426
  • If you don't ask .... :)
  • Reviews:

    What is it?

Hi Mark, neat idea, but for some reason I cannot get it to work? but I am still playing with it.

I am assuming the $s2reId is a call to the sobi2Id but you have a clone or something, correct?  or do you have an additional defined function for $s2reId in your gallery.class.php?

:grin: cheers :grin:

hmm - just re-read your using this in details view, I am trying to do similar in v-card view - I get the 'Fatal error: Call to a member function on a non-object' error - any ideas on how to get this to work in a v-card view?
« Last Edit: 24. August 2007, 06:29:50 by gwmbox »
Country: Australia Australia |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline aboututila

gwmbox,

(1) Whoops, my mistake. Yes I had been working on a clone.
I have modified my previous message to change the variable $s2reId to $sobi2Id in the example above.

(2) sobi2.vc.tmpl.php works differently to sobi2.details.tmpl.php

The code example I have given above, only works in sobi2.details.tmpl.php

sobi2.vc.tmpl.php is called as a function and the variable/array values available to it are only those that are passed via function declaration in the initial line of sobi2.vc.tmpl.php , namely;
function sobi2VCview($id, $style, $ico, $img, $title, $fieldsObjects, $fieldsFormatted, $plugins, $editButton = null, $deleteButton = null) {

to see what values are passed add the following "debugging" code into your sobi2.vc.tmpl.php after the function declaration;

print 'Line '.__LINE__.' $id structure <pre>'; print_r ($id); print "</pre><br />\n";
print 'Line '.__LINE__.' $style structure <pre>'; print_r ($style); print "</pre><br />\n";
print 'Line '.__LINE__.' $ico structure <pre>'; print_r ($ico); print "</pre><br />\n";
print 'Line '.__LINE__.' $title structure <pre>'; print_r ($title); print "</pre><br />\n";
print 'Line '.__LINE__.' $fieldsObjects structure <pre>'; print_r ($fieldsObjects); print "</pre><br />\n";
print 'Line '.__LINE__.' $fieldsFormatted structure <pre>'; print_r ($fieldsFormatted); print "</pre><br />\n";
print 'Line '.__LINE__.' $plugins structure <pre>'; print_r ($plugins); print "</pre><br />\n";

The number of images is passed embedded in a formatted string in the $plugins array.
You would then need to write some PHP code to retrieve the number of images from this formatted string.

I hope this helps - Mark
Country: Honduras Honduras |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline ~GW~

  • Sobi Experte
  • ****
  • Posts: 426
  • If you don't ask .... :)
  • Reviews:

    What is it?

Thanks Mark I'll give that a try and see how I go :)

:grin: cheers :grin:
Country: Australia Australia |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline kingbt

HI,
What code should I add to display a counter in vc.
Thank you
Country: Romania Romania |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline Trinity

  • Sobi Team
  • Development
  • Sobi Hero
  • *
  • Posts: 8943
  • Reviews:

    What is it?

    • Sobi Team Member
Hi,

this is a standard function of the Gallery. Take a look to the administration panel of the Gallery plugin (Info).

Trinity
Support SobiPro - Submit a review on JED
If you want ongoing development for SobiPro and new applications being developed we need your review for SobiPro in the Joomla Extensions Directory.
Thank you very much :w00t:
Country: Germany Germany |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile Sigsiu.NET

Offline kingbt

Indeed, so it is.
But I want to customise the vc and I want to put gallery thumbnail to left of vc (found the code in forum) and the count images to right (2 posibilities: 1 use gallery options to display only image count, 2 count the files from directory).
Country: Romania Romania |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline suhasmarcus

  • Sobi Newbie
  • *
  • Posts: 2
Gallery plugin problem in I.E
« Reply #8 on: 10. June 2011, 11:08:08 »
I have problem in viewing gallery images in I.E
Well in firefox gallery images are working fine but in I.E when i clicked the thumbnail of the images it opening in popup. Image is opening in the same page.Only the image is opening in the same page. I have to hit back button to go to site again view the next image.
Can you help me regarding this...
Country: India India |  OS: Windows 7/Server 2008 R2 Windows 7/Server 2008 R2 |  Browser: Chrome 12.0.742.91 Chrome 12.0.742.91 | View Profile

Tags: