[Zope] URL Hell

J. Cameron Cooper jccooper at jcameroncooper.com
Wed Dec 10 22:16:08 EST 2003


Tim Zegir wrote:

> I have a database with a table full of customers and one of the fields 
> in the database contains the customer’s website.
>
> I have a ZSQL method that gets the data then a Page Template.
>
> The part of the Page Template that renders the web page is as follows
>
> <p>Webpage:
>
> <a tal:attributes="href rdata/webpage" 
> tal:content="rdata/webpage">webpage</a>
>
> </p>
>
> Now if I view this in a web browser it takes me to this link 
> http://my_ip_address:8080/plone_instance/the_url_i_want_it_to_take_me_to 
> (eg www.foo.com <http://www.foo.com/>)
>
> How do I stop it putting the plone instance in front of my webpage?
>
Basic HTML behaviour is your culprit. I bet if you look at the source
you'll find it looks like::

<a href="www.foo.com">www.foo.com</a>

Problem is this looks to the web browser like an address relative to the
current URL path. You must always have a protocol in an external link.
So you can fix the source of the data or say::

<a tal:attributes="href string:http://${rdata/webpage}"
tal:content="rdata/webpage">webpage</a>

That should do the trick.

--jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."






More information about the Zope mailing list