Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Create link only if file exists

Apologies if this is the dumbest newbie question so far this year.

I'm making a website for a talent agency. All the clients have blurbs, and about 75% of the clients have CVs. I want to  link from a client's blurb to a client's CV only if the CV exists. Is there a way to automatically check to see if the CV exists (if the CV and the blurb have the same name but are in different folders)?

In the help there is lots about dealing with missing fields but I can't figure out how to use this to check to see if a file exists.

Thanks in advance for any help.

andy bell
Friday, January 02, 2004

can you check the filename variable for blank?

John

john cesta
Friday, January 02, 2004

Are you suggesting something like this:

{$ if nonblank (fileName "images/pic_trey_farley_sm_01.jpg")  $}
<img height="135" src="images/pic_trey_farley_sm_01.jpg">
{$ endif $}

This gives the error message:
'If: Expected Variable name, for example, "If blank .body"'.
(The problem being, I think, that (filename "name") is a condition and if blank takes a variable)

andy bell
Friday, January 02, 2004

You could do something like this.
In the extra1 field of the blurb article put
{ $ foreach 1 x in "images/pic_trey_farley_sm_01.jpg"} {$ x.link $} {$ next $}

Then in the template or article body put
{$ if nonblank  .extra1 }
<img height="135" src="{$. extra1 $}">
{$ endif $}

This won't completly automate the link since you'll have to explicitly put the filename of the target file into the loop in the extra1 field.  You might be better off simply putting the magic name of the target file into a field in the related article.

 

Ken McKinney
Friday, January 02, 2004

Thanks John and especially Kenny,

Has anyone got any ideas how to COMPLETELY automate the link? I am transfering a medium size site into CityDesk. This problem recurrs so frequently and the end users are so scatty and artistic, that I really need to automate it totally. Also, to keep using the existing design, the picture needs to go in the template part of the page.

To ask the question a different way. In the help on Dealing With Missing Fields it says:
For example, a real-estate listing site might want to display pictures of the homes for sale if they are available, and automatically substitute in a picture of Neuschwanstein Castle otherwise.

Maybe I'm stupid, but I can't work out how to do this from the code examples given. If somone could show me how to automatically substitute a picture of Neuschwanstein Castle, I think I could use that to solve my problems.

Thanks once again and merry 2004.

andy bell
Monday, January 05, 2004

I don't think you can bullet proof CityDesk from users or to accommodate what users might do. I can't even bullet proof a site from myself.  You can do a little better by using the Contributors version.

tk
Monday, January 05, 2004

One approach would be to put the blurb and the cv in the same citydesk article.

For the blurb pages, create a template that only has the elements that you need for the blurb. You'll need to have a check to see if the cv is non-blank, and if so, include a link to the cv page.

For the cv page, you could publish an alternate version of the same article, using a different template. This part is pretty well discussed in the documentation.  I don't know of any way to not publish the cv's that would be blank, but they would not be linked to from the blurb version of the article.

Leroy
Tuesday, January 13, 2004

*  Recent Topics

*  Fog Creek Home