WebsiteBaker Community Forum

General Community => Off-Topic => Topic started by: crnogorac081 on May 27, 2011, 04:39:09 PM

Title: php help
Post by: crnogorac081 on May 27, 2011, 04:39:09 PM
Hi,

I could find a solution on web, or maybe I searched for a wrong term, but how can I wrap a link around text ?

for example, I have this code:
Code: [Select]
<a href="..."><div> some text...text ....text .</div></a> but it doesnt pass validation as I am wrapping block element with inline element. What I am trying to find is how to put a link over text only (inside div tags)
Code: [Select]
<div> <a href="...">some text...text ....text .</a></div>

any help would be much appreciated ;)
cheers,
Ivan
Title: Re: php help
Post by: DarkViper on May 27, 2011, 06:49:02 PM
Block elements within Inline elements are not permitted.
You can handle it maybe, taking a <span> instead of the <div> and set it's display attribute to 'block' or 'inline-block'.
Without guaranty  :wink:
Title: Re: php help
Post by: crnogorac081 on May 27, 2011, 07:06:48 PM
i know,it is a part of template for the module I am working on, the text supposed to be a description, and I need to put a link on description, but then, if description text is aligned: center, I have a block element.. so I am wondering if some experience coder can help on this piece of code.. I found some simular examples with preg match or preg replace, but I havent found a solution for this :(

What I exactly need:
Code: [Select]
$link = '<a href="http://www...."> </a>';
$description = '<div> some <p>dummy text</p>...dummy text ....<span>text</span>......test.... .</div>';

Now I need function to locate pure text and put a link ( $link ) around each peace of text in $description

The result should be something like this:
$description = '<div> <a href="http://www....">some</a> <p><a href="http://www....">dummy text</a></p><a href="http://www....">...dummy text ....</a><span><a href="http://www....">text</a></span><a href="http://www....">......test....</a></div>';