On Sun, Nov 7, 2010 at 8:51 AM, euromark <[email protected]> wrote:
> i did partly succeed
> http://pastebin.com/NfmDC27L
>
> the protocol is stripped and the length is shortened (if desired)
> BUT it appends the additional option keys/values as attributes of the
> link tag:
>
> <a href="http://www.cot.ag/cuIb2Q/eruierieriu-erjekr"; stripProtocol=0"
> maxLength="12">
> etc
>
> Details:
>
> Equal expectation fails at character 69 with [Text with a url <a
> href="http://www.cot.ag/cuIb2Q/eruierieriu-erjekr";>www.cot.ag/c...</a>
> and more] and [Text with a url <a href="http://www.cot.ag/cuIb2Q/
> eruierieriu-erjekr" maxLength="12">www.cot.ag/c...</a> and more] at [H:
> \...\site\plugins\tools\tests\cases\helpers\text_ext.test.php line 44]
>
>
> How can i remove them before the link is created but after i passed
> them to the static prepareLinkName() function?
> thx
>
>
> On 7 Nov., 14:11, euromark <[email protected]> wrote:
>> hey guys
>> currently the text helper autoLinkUrls() creates links with the same
>> name as href:
>>
>> texthttp://www.url.demore text
>> =>
>> text < href="http://www.url.de";>http://www.url.de</a> more text
>>
>> this gets really ugly if the urls are 100 to 200 chars long.
>> how could i extend that method in order to achieve something like
>> that:
>>
>> a) strip protocol (http://) from name (unnecessary - google does it in
>> chrome as well) if "stripProtocol"=>true:
>> text < href="http://www.url.de";>www.url.de</a> more text
>>
>> b) shorten url if param "maxLength"=>x is passed (e.g. 15):
>> text < href="http://www.url.de/somehundredschars";>www.url.de/some...</
>> a> more text
>>
>> this way it is way more readable and doesnt destroy the layout or take
>> unncessary space.
>> the current method seems to call $Html->link() inside
>> "create_function". I dont know if that can be overridden...
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>


You need to remove your custom options before calling
$HtmlHelper::link(). Or you could simply pass them as separate params
to your own method instead of including them in $htmlOptions.

Also, another way to do this might be to first pass $text to
TextHelper::autoLinkUrls(), then massage the result:

function autoLinkUrls($text, $htmlOptions = array(), $stripProtocol =
true, $maxLength = 12)
{
        $text = TextHelper::autoLinkUrls($text, $htmlOptions);
        
        /* now use preg_replace_callback() to pull the link text
         * and transform according to your params
         */
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to