Author Topic: [SOLVED with Custom Code] Using Gallery instead of Icon and Logo  (Read 7630 times)

0 Members and 1 Guest are viewing this topic.

Offline sunon

[SOLVED with Custom Code - See Solution]
Hi,

I was to change featured module so that instead of using the logo, it will grab the first gallery image and display that instead.
What code changes are necessary.

Also I think this may be a good feature to include in future versions since a lot of people most probably want to have access to showing gallery images instead of logo or icons.

Thanks
« Last Edit: 07. February 2011, 18:11:45 by aboututila »
Country: South Africa South Africa |  View Profile


Offline aboututila

Re: Using Gallery instead of Icon and Logo
« Reply #1 on: 20. October 2008, 16:58:32 »
I was to change featured module so that instead of using the logo, it will grab the first gallery image and display that instead.
What code changes are necessary.
(1) You would need to modify mod_sobi2featured.xml, and add a new parameter to say use Gallery images.
You could choose the 'first' Gallery image to use, but what if not every Entry had a Gallery associated with it?

(2) You would need to add some code in mod_sobi2featured to get the image from the Gallery.
You would need to include error handling code to ensure that the Gallery image actually exists.
I am not familiar with the detailed workings of the SOBI2 Gallery plugin so I do not know if you will need different code for different versions of the plugin.

(3) If you are the only person adding entries to the SOBI2 Directory an easier work-around to the problem may be to use Custom Fields.
Create a Custom Field that contains the HTML code to display the required Image for each Entry;
For example;
<div class=myFeaturedGalleryImage><img border="0" alt="myAlternativeTextForThisImage" src="myPathToGalleryImageForThisEntry" width="MyGalleryImageWidth" height="MyGalleryImageHeight"></a></div>
and then specify in the module settings to output this custom field via the parameter 'Display Custom Fields with ID:'

Obviously, this is practical only if you are the only person adding SOBI2 entries, or this creates a high administrative workload if you have to go back and update other peoples entries.

(4) It is not a trivial issue to build this feature into the standard Module mod_sobi2featured code and maintain compatibility with all SOBI2 versions, all Joomla versions and all Gallery plugin versions.

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

Offline anakyn

Re: Using Gallery instead of Icon and Logo
« Reply #2 on: 03. July 2009, 08:09:37 »


Hi,

I was to change featured module so that instead of using the logo, it will grab the first gallery image and display that instead.
What code changes are necessary.

Also I think this may be a good feature to include in future versions since a lot of people most probably want to have access to showing gallery images instead of logo or icons.

Thanks

Hi Sunon,

Have change the code to get desired result? Are interested me this change. Tell me how you did.

Thanks!
Country: Germany Germany |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile Oferte de Cazare

Offline aboututila

Re: Using Gallery instead of Icon and Logo
« Reply #3 on: 03. July 2009, 15:50:30 »
I was to change featured module so that instead of using the logo, it will grab the first gallery image and display that instead.
What code changes are necessary.

The code changes are not simple, since among other things you will need to test if the gallery plug-in is installed or not.
I am in the process of doing a major re-write of mod_sobi2featured. Once that re-write is complete it will be easier for people to take the mod_sobi2featured base code and re-write sections for their own purposes. Currently this is difficult.
[Update 10-Aug-2009 mod_sobi2simplefeatured v2.0.6 is now available]

Regards - Mark
« Last Edit: 11. August 2009, 01:56:49 by aboututila »
Country: Honduras Honduras |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline anakyn

Re: Using Gallery instead of Icon and Logo
« Reply #4 on: 06. July 2009, 10:49:47 »
thanks for feedback.
Country: Germany Germany |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile Oferte de Cazare

Offline kleddo

Re: Using Gallery instead of Icon and Logo
« Reply #5 on: 14. August 2009, 11:38:19 »
hey aboututila,

could you please explain me the steps, for upgrading my module for using gallery pics?
I already updated to the new version 2.06. Thanks a lot in advance.

kleddo
Country: Germany Germany |  OS: Windows XP Windows XP |  Browser: Firefox 3.0.13 Firefox 3.0.13 | View Profile

Offline aboututila

Re: Using Gallery instead of Icon and Logo
« Reply #6 on: 14. August 2009, 16:54:11 »
hey aboututila,

could you please explain me the steps, for upgrading my module for using gallery pics?
I already updated to the new version 2.06. Thanks a lot in advance.


kleddo,
The PHP code for mod_sobi2simplefeatured has been 'cleaned up' and reorganized, but what you request is not a simple change of one or two lines of code. To achieve what you require will require medium to advanced level PHP programming skills.

I am willing to answer any technical questions about the existing mod_sobi2simplefeatured PHP code, but I do not have any spare time at the moment to write the actual code required for the feature you request.

If enough people vote for this feature, I may consider adding it to a later mod_sobi2simplefeatured update.

Regards - Mark
Country: Honduras Honduras |  OS: Windows XP Windows XP |  Browser: Firefox 3.5.2 Firefox 3.5.2 | View Profile

Offline hifut

Re: Using Gallery instead of Icon and Logo
« Reply #7 on: 28. August 2009, 20:39:10 »
I used the following in the default.php (or your template name), this worked for me. Shows the first gallery image if it exists as either a gif or a jpg.

Code: [Select]
      $thumb_jpg="images/com_sobi2/gallery/".$entry['itemId']."/".$entry['itemId']."_thumb_1.jpg";
      $thumb_gif="images/com_sobi2/gallery/".$entry['itemId']."/".$entry['itemId']."_thumb_1.gif";
      if (file_exists("$thumb_jpg")) {
        echo "<a href='".$entry['href']."'>";
        echo "<img src=\"$thumb_jpg\" border=1 >";
        echo "</a>";
      } else {
        if (file_exists("$thumb_gif")) {
          echo "<a href='".$entry['href']."'>";
          echo "<img src=\"$thumb_gif\" border=1 >";
          echo "</a>";
        }
      }
« Last Edit: 28. August 2009, 23:37:08 by aboututila »
Country: United Kingdom United Kingdom |  OS: Windows XP Windows XP |  Browser: Firefox 3.5.2 Firefox 3.5.2 | View Profile

Offline aboututila

Re: Using Gallery instead of Icon and Logo
« Reply #8 on: 28. August 2009, 23:34:28 »
Thanks,
Good to know.
I assume you added your code into the file mysite/modules/mod_sobi2simplefeatured/tmpl/default.php
somewhere in the code section
Code: [Select]
# Output HTML for each Entry
foreach ($entries as $entry){
# output HTML for Entry wrapper start division
$my_module->echoHTML_Entry_Wrapper_Start();

# output HTML for Title, if required
$my_module->echoHTML_Title($entry);

# output HTML for Icon, if required
$my_module->echoHTML_Icon($entry);

# output HTML for Image, if required
$my_module->echoHTML_Image($entry);

# output HTML for Custom Fields, if required
$my_module->echoHTML_CustomFields($entry);

# output HTML for Hits Counter, if required
$my_module->echoHTML_HitsCounter($entry);

# output HTML for Text Link to Entry Details, if required
$my_module->echoHTML_TextLink($entry);

# output HTML for Entry wrapper end division
$my_module->echoHTML_Entry_Wrapper_End();

# End Output HTML for each Entry
}
and set the module configuration
Output Controls - SOBI2 standard data fields
Title=No
Icon = No

or replaced the lines
Code: [Select]
# output HTML for Icon, if required
$my_module->echoHTML_Icon($entry);

# output HTML for Image, if required
$my_module->echoHTML_Image($entry);
with your code.

Note: If others are thinking of doing this, I recommend they make a new Custom Module Template
and add modifying the code in their new Custom Module Template.

Note: A BB Code parser 'bug' in this version of the SMF SOBI Forum software sometimes does not display the instructions for creating a new Module Template correctly. If you do not see the example code included with these instructions, keep refreshing your Browser until it becomes visible.

Regards - Mark
« Last Edit: 28. August 2009, 23:48:45 by aboututila »
Country: Honduras Honduras |  OS: Windows XP Windows XP |  Browser: Firefox 3.5.2 Firefox 3.5.2 | View Profile

Offline hifut

Re: [SOLVED with Custom Code] Using Gallery instead of Icon and Logo
« Reply #9 on: 29. August 2009, 12:48:31 »
Hi Mark, yes, put the code wherever you want the gallery image to appear in the mysite/modules/mod_sobi2simplefeatured/tmpl/default.php

I am struggling with another issue however, I would like to output a selected custom field, but I am having difficulty. Rather than output the entire custom fields in one go, I would like to selectively output say custom field id 3 in one location and custom field id 13 in another.

I am sure it must be simple but cannot figure it out, I think tiredness isn't helping!

Something along the lines of:

Code: [Select]
echo $entry['field_description'];

in the default.helper.php file.

I just can't figure out the syntax/variables needed for the line.

Was hoping you could help. Completely off topic I know. Great module by the way!

Ian.
« Last Edit: 29. August 2009, 12:51:05 by hifut »
Country: United Kingdom United Kingdom |  OS: Windows XP Windows XP |  Browser: Firefox 3.5.2 Firefox 3.5.2 | View Profile

Tags: