Page 1 of 1
[SOLVED] Banner-module: How to get image text below banner?
Posted: Sat Jan 27, 2007 7:43 pm
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
Re: Banner-module: How to get image text below banner?
Posted: Wed Mar 21, 2007 4:02 pm
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
Re: Banner-module: How to get image text below banner?
Posted: Wed Mar 21, 2007 4:20 pm
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
Re: Banner-module: How to get image text below banner?
Posted: Wed Mar 21, 2007 4:28 pm
by Steppenwolf
Ronny,
sorry, it was a mistake:
instead of
"$text
"
it should be
"
$text"
Eberhard
Re: Banner-module: How to get image text below banner?
Posted: Wed Mar 21, 2007 4:30 pm
by RonnyK
Thanks Steppenwolf,
That works like charm. An applaud to you.
Ronny