[SOLVED] Banner-module: How to get image text below banner?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

[SOLVED] Banner-module: How to get image text below banner?

Post by RonnyK »

I'm using the banner-module and I want some text of the banner to be visible as well, as it now only shows images. If I could show the description, or the alt-text below the image, this would be great. I'm calling the module as follows:

Code: Select all

      {cms_module module='Banners' category="Banners"}
Ronny
Last edited by RonnyK on Wed Mar 21, 2007 4:30 pm, edited 1 time in total.
Steppenwolf
Forum Members
Forum Members
Posts: 19
Joined: Fri Dec 01, 2006 11:22 am
Location: Germany

Re: Banner-module: How to get image text below banner?

Post by Steppenwolf »

Hi Ronny,

here is a solution for you:

Add this user defined tag "BannerText":
$category = $params['category'];
global $gCms;
if( !isset( $gCms->modules['Banners'] ) ||
    !isset( $gCms->modules['Banners']['object'] ) )
{
  return;
}
$returnid = "";
if (isset($gCms->variables['pageinfo']))
{
  $returnid = $gCms->variables['pageinfo']->content_id;
}
$banners = $gCms->modules['Banners']['object'];
$banner_param['category'] = $category;
ob_start();
$banners->DoAction( 'default', 0, $banner_param, $returnid );
$bannerlink = ob_get_contents();
ob_end_clean();
if( preg_match( "/alt="([^"]*)"/", $bannerlink, $matches ) == 1 )
{
  $text = $matches[1];
  $bannerlink = str_replace( "", "$text", $bannerlink );
}
echo( $bannerlink );
Instead of including your banners the common way
{cms_module module='Banners' category="Banners"}
now you do it this way:
{BannerText category='Banners'}
This prints your image's alt text below/after the image. (If you want to add a line break before the text, use "$text
")

Hope, this helps you
Eberhard
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Banner-module: How to get image text below banner?

Post by RonnyK »

Steppenwolf,

thanks a lot so far, but I don't get the text on the next line, even with the
, it still writes it next to the banner instead of on the next line.


The last lines of the changed UDT:

Code: Select all

{
  $text = $matches[1];
  $bannerlink = str_replace( "</a>", "$text<br /></a>", $bannerlink );
}
echo( $bannerlink );
If you check the site, www.terspille.nl, you see the banner on the left, with the name of the banner on the side.

Ronny
Steppenwolf
Forum Members
Forum Members
Posts: 19
Joined: Fri Dec 01, 2006 11:22 am
Location: Germany

Re: Banner-module: How to get image text below banner?

Post by Steppenwolf »

Ronny,

sorry, it was a mistake:

instead of
"$text
"
it should be
"
$text"
Eberhard
Last edited by Steppenwolf on Wed Nov 07, 2007 7:15 pm, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Banner-module: How to get image text below banner?

Post by RonnyK »

Thanks Steppenwolf,

That works like charm. An applaud to you.

Ronny
Post Reply

Return to “CMSMS Core”