stupid question: first 7 chars of an URL
Hi there, can't figure out how to write the frist 7 characters of an URL string to a new var. <dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work. <dtml-if "urlvar[0:7] == 'http://'"> The problem is the ':'. May be one have to use url_quote. But can't combine dtml-let drml-call with url-quote to create a new var. Thank you Marcus
Hi Marcus, <dmtl-let firstseven="urlvar[0:7]"> <dtml-var firstseven> </dtml-let> schoppa@uni-bielefeld.de wrote:
Hi there,
can't figure out how to write the frist 7 characters of an URL string to a new var.
<dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work.
<dtml-if "urlvar[0:7] == 'http://'">
The problem is the ':'. May be one have to use url_quote. But can't combine dtml-let drml-call with url-quote to create a new var.
Thank you Marcus
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Chris, this will not work because of the ':' in URL var I did it like this. Any better way? <dtml-if expr="_.string.split(url,'://')[0] == 'http' or _.string.split (url,'://')[0] == 'ftx'"> extern URL </dtml-if> Bye Marcus Zitiere Chris McDonough <chrism@digicool.com>:
Hi Marcus,
<dmtl-let firstseven="urlvar[0:7]"> <dtml-var firstseven> </dtml-let>
schoppa@uni-bielefeld.de wrote:
Hi there,
can't figure out how to write the frist 7 characters of an URL string
to a new
var.
<dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work.
<dtml-if "urlvar[0:7] == 'http://'">
The problem is the ':'. May be one have to use url_quote. But can't combine dtml-let drml-call with url-quote to create a new var.
Thank you Marcus
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Chris, sorry. Your are right. Didn't work because of dmtl instead of dtml ;-) Bye Marcus Zitiere Chris McDonough <chrism@digicool.com>:
Hi Marcus,
<dmtl-let firstseven="urlvar[0:7]"> <dtml-var firstseven> </dtml-let>
schoppa@uni-bielefeld.de wrote:
Hi there,
can't figure out how to write the frist 7 characters of an URL string
to a new
var.
<dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work.
<dtml-if "urlvar[0:7] == 'http://'">
The problem is the ':'. May be one have to use url_quote. But can't combine dtml-let drml-call with url-quote to create a new var.
Thank you Marcus
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
It works for me: ----------------------------------------- <dtml-let urlvar="'http://'"> <dtml-if "urlvar[0:7]=='http://'"> The URL is: <dtml-var "urlvar[0:7]"> <dtml-else> The URL is NOT ... </dtml-if> </dtml-let> ------------------- result: The URL is: http:// schoppa@uni-bielefeld.de wrote:
Hi there,
can't figure out how to write the frist 7 characters of an URL string to a new var.
<dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work.
<dtml-if "urlvar[0:7] == 'http://'">
The problem is the ':'. May be one have to use url_quote. But can't combine dtml-let drml-call with url-quote to create a new var.
Thank you Marcus
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[<schoppa@uni-bielefeld.de>] can't figure out how to write the frist 7 characters of an URL string to a new var. <dtml-var urlvar[0:4]> works fine. <dtml-var urlvar[0:7]> doesn't work. <dtml-if "urlvar[0:7] == 'http://'"> [Tom] The expression urlvar[0:7] is correct, but you can't assign it to a variable or display it with a dtml-if instruction. You could display it with <dtml-var "urlvar[0:7]">. For how to assign it to a new variable, there are several ways, including REQUEST.set and dtml-let. You have to read up on how to do it to suit what you want to do. Tom P
participants (5)
-
Chris McDonough -
Jose Soares -
marcus.schopen@uni-bielefeld.de -
schoppa@uni-bielefeld.de -
Thomas B. Passin