Page 1 of 1

PHP and ALT tags without ECHO

Posted: Sun Aug 03, 2003 1:57 pm
by kanshou
I need to know how to put an alt tag into a link that is being generalted by an array. for example

Code: Select all

<?php
function viewjcn()
	{
		commonHeader();
		if ($GLOBALS['jcn'] == '')
		{
			print(STR_WO_NEEDJCNERR);
			return;
		}

		if ($GLOBALS['seq'] != '')
		{
			$obj = CreateObject('dcl.htmlWorkOrderDetail');
			$obj->Show($GLOBALS['jcn'], $GLOBALS['seq']);
			return;
		}

		$objView = CreateObject('dcl.boView');
		$objView->style = 'report';
		$objView->title = STR_WO_RESULTSTITLE;

		$objView->AddDef('filter', 'jcn', $GLOBALS['jcn']);
		if (IsSet($GLOBALS['seq']) && $GLOBALS['seq'] != '')
			$objView->AddDef('filter', 'seq', $GLOBALS['seq']);

		$objView->AddDef('columns', '',
			array('jcn', 'seq', 'dcl_wo_type.type_name', 'products.name', 'priorities.name', 'severities.name', 'responsible.short', 'contact', 'deadlineon', 'summary'));

		$objView->AddDef('order', '', array('jcn', 'seq'));

		$objView->AddDef('columnhdrs', '',
			array(STR_WO_JCN, STR_WO_SEQ, STR_WO_TYPE, STR_WO_PRODUCT, STR_WO_PRIORITY,	STR_WO_SEVERITY, STR_WO_RESPONSIBLE, STR_WO_CONTACT, STR_WO_DEADLINE, STR_WO_SUMMARY));

		$objHV = CreateObject('dcl.htmlView');
		$objHV->Render($objView);
	}
?>
And this is the function that renders $objView

Code: Select all

<?php
function Render($objView)
	{
		global $dcl_info;

		if (!is_object($objView))
		{
			print('[htmlView] ' . STR_VW_VIEWOBJECTNOTPASSED);
			return;
		}

		// check to see if we have the method specified
		if (!is_object($this->oCallback) || ($this->sCallback == '' && $this->sFilterCallback == ''))
		{
			$this->oCallback = null;
		}

		$whatObject = $this->GetClassNameForTable($objView->table);
		if ($whatObject == '')
			return;

		$objDB = CreateObject('dcl.' . $whatObject);
		$objDB->Connect();
		$bNext = false;
		$bPrev = false;
		$sForm = '';
		$result = 0;

		if ($objView->numrows > 0 || $objView->startrow > 0)
		{
			$url = $objView->GetURL();
			$sForm = $this->GetPagerFormElements($objView, $bPrev, $bNext);
			$result = $objDB->LimitQuery($objView->GetSQL(), $objView->startrow, $objView->numrows);
		}
		else
			$result = $objDB->Query($objView->GetSQL());

		if ($result == -1)
		{
			print('<center><h4>');
			printf(STR_VW_QUERYERR, '');
			print('</h4></center>');
			return;
		}
?>
The data in column 'jcn' is a link and it is being called from a field in the database. Any ideas/help would be greatly appreciated!!!
Thanks,
Rand

Posted: Sun Aug 03, 2003 6:38 pm
by jmarcv
I don't see where your link tags get created in the code, so without decipering your code, I will just flat out say that last time I checked, alt tags only work on images. I have created an alt substitute in Javascript to generate alt tags for text, and that is because there was no way I saw to do it with HTML. So, what EXACTLY is your question?
'How do I make alt tags for text?
Or, did I miss something?

Posted: Sun Aug 03, 2003 6:43 pm
by kanshou
nah, you hit it right on the head, "how do I make alt tags for text?" was my question.. but thanks for the insight.

Posted: Sun Aug 03, 2003 8:21 pm
by EvilWalrus

Code: Select all

<a href="#" title="This is the alt text for the link">w00t</a>
that should work

Posted: Sun Aug 03, 2003 8:31 pm
by jmarcv
EvilWalrus

Whoa!!! learn something every day here! Well, I guess my little project 2 years ago wasn't in vain, I learned some javascript.

Doesn't work on netscape 4.7 FYI

Posted: Sun Aug 03, 2003 9:31 pm
by jason
Just for reference, alt attributes for text do not exists. The title tag and the alt tag are two distinctly different tags for different purposes.

Simply put, the alt attribute is use in place of an image. If the image is shown, and the person puts his cursor over the image, then some browsers will show this alt tag. This should NOT be the case. Rather, that is what the title attribute is for.

The title attribute is used to define the link or image more clearly. The alt attribute is the alternate to be used if the picture is not shown.

So, when the picture is not shown, the alt attribute should be an accurate replacement of the picture. What most people use the alt attribute for, however, is the purpose of the title attribute.

Posted: Wed Aug 06, 2003 10:06 pm
by kanshou
Thanks Jason and EW, the title tag was exactly what I was looking for to solve most of my issues.