alt text for [ID X]{IMAGE:..... ?

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

alt text for [ID X]{IMAGE:..... ?

Post by update »

HI
I'm looking for a solution to pass some "Alt" text to this one:

Code: Select all

[ID home]{IMAGE:img/house.gif}[/ID]
Is it possible - if yes, how? Searching the forum hmm... :|
Passing along something like

Code: Select all

[ID home]{IMAGE:img/house.gif|nach hause telefonieren}[/ID]
shuts off the pic completely
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: alt text for [ID X]{IMAGE:..... ?

Post by flip-flop »

Hi claus,

For me it isn´t possible. :( Please write your own TAG or make a patch in front.func.inc.php :?

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: alt text for [ID X]{IMAGE:..... ?

Post by juergen »

Ok, called it {A_IMAGE:pic_name:alt-and-titleText:id-or-alias}

put this in frontend_render as anyname.php

Code: Select all

<?php


// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------





$content["all"] = preg_replace('/\{A_IMAGE:(.*?):(.*?):(.*?)\}/ie', 'liste26("$1","$2","$3")', $content["all"]);

function liste26($bild,$alt,$ID) {

if (is_numeric($ID)) {

	$lista='<a href="index.php?aid='.$ID.'" class="phpwcmsIntLink">';

	 
}
	else {
  
    $lista='<a href="index.php?'.$ID.'" class="phpwcmsIntLink">';

  }

 $lista =$lista. '<img src="picture/'.$bild.'" alt ="'.$alt.'" title="'.$alt.'"> </a>';
return($lista);
}
?>
worked for me, tested in 1.3.x with rewrite on, should also do with off

have fun

Jürgen
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: alt text for [ID X]{IMAGE:..... ?

Post by update »

Thanks a lot!
Will give it a try...
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: alt text for [ID X]{IMAGE:..... ?

Post by update »

This is working like nothing :lol:
Only to adjust the img path and gone.. Thanks again
If the img cannot be found it still shows the title/alt text as a link. 8)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: alt text for [ID X]{IMAGE:..... ?

Post by juergen »

claus wrote:If the img cannot be found it still shows the title/alt text as a link. 8)
this is only why I am to stupid to change the code that it likely draws some nice pictures if there is no material :D
fopulu
Posts: 359
Joined: Tue 2. May 2006, 14:19
Location: Rhein-Main

Re: alt text for [ID X]{IMAGE:..... ?

Post by fopulu »

Hi Claus,

maybe this could help you.... i had the same problem and fixed it in the front.func.inc.php
http://forum.phpwcms.org/viewtopic.php?p=95894#p95894

Have a look around line 1335:

Code: Select all

// internal Link to article ID
	$search[1]		= '/\[ID (\d+)\](.*?)\[\/ID\]/';
	$replace[1]		= '<a href="index.php?aid=$1" class="phpwcmsIntLink" title="$2">$2</a>';
The title or alt text is in this case the same as the link is called....
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: alt text for [ID X]{IMAGE:..... ?

Post by update »

Hi,
I've "enhanced" the anyname.php a little bit. Now the output is valid and some spaces are removed. Have a look

Code: Select all

<?php

// ----------------------------------------------------------------
// obligate check for phpwcms constants
	if (!defined('PHPWCMS_ROOT')) {
		die("You Cannot Access This Script Directly, Have a Nice Day.");
	}
// ----------------------------------------------------------------
	// call it like so: {A_IMAGE:pic_name:alt-and-titleText:id-or-alias}
	// example: {A_IMAGE:house.gif:home:home}
	//the script is now accessing the picture/img folder, so you have to change it accordingly to the correct path
	$content["all"] = preg_replace('/\{A_IMAGE:(.*?):(.*?):(.*?)\}/ie', 'liste26("$1","$2","$3")', $content["all"]);

	function liste26($bild,$alt,$ID) {

		if (is_numeric($ID)) {

			$lista='<a href="index.php?aid='.$ID.'" class="phpwcmsIntLink">';

		}
		else {

			$lista='<a href="index.php?'.$ID.'" class="phpwcmsIntLink">';

		}

	$lista =$lista. '<img src="picture/img/'.$bild.'" alt="'.$alt.'" title="'.$alt.'" /></a>';
	return($lista);
	}
?>
This is working!

@fopulu
thank you -I checked your recommendation - this is working too:

Code: Select all

	$replace[1]		= '<a href="index.php?aid=$1" class="phpwcmsIntLink" title="$1">$2</a>';
and shows the number of the article (using $2 instead of $1 throws an error (v 135 071205) )

But as mentioned before somewhen: dealing with the source is always something which keeps at least me off to use this or that nice mod or addon (I've been starting with phpwcms doing it like this, added everything and became quite unhappy while doing my first update) :wink:
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
Post Reply