[Zope] How do I check for existence of a page?

Casey Duncan cduncan@kaivo.com
Wed, 28 Feb 2001 09:27:21 -0700


Joel Burton wrote:
> 
> We have our staff listed under /staff, so that you might find me as
> /staff?staffname=joel
> 
> I'd like the return page from this method to check if I have a
> homepage on the site, and if so, provide a link. Right now, I'm doing
> this as:
> 
> <dtml-in "PARENTS[1].home.objectIds(['Folder'])">
>   <dtml-if "_['sequence-item']==staffname">
>     <a href="/home/&dtml-staffname;">There is a home page</a>
>   </dtml-if>
> </dtml-in>
> 
> (cycle through folders under the '/home' directory, check the seq-id
> against my name, and if so, generate a link.)
> 
> Is there a cleaner way to do this?
> 

Much:

<dtml-with name="home" only>
	<dtml-if expr="_.hasattr(home, staffname)">
     		<a href="/home/&dtml-staffname;">There is a home page</a>
	<dtml-else>
.		No home page found.
	</dtml-if>
</dtml-with>

or

<dtml-with name="home" only>
	<dtml-try>
		<a href="<dtml-var expr="_[staffname]" url>">There is a home page</a>
	<dtml-except KeyError>
		No home page found.
	</dtml-try>
</dtml-with>

hth
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>