Jump to content


Quick Question About Testing If Doc Has Content


3 replies to this topic

#1 doze

    Etomite Forum Fan

  • Member
  • Pip
  • 119 posts

Posted 11 December 2005 - 04:20 PM

Hi,

I'm making templates to Etomite and I just started to use Etomite last week, so need some basic help..

I'd like to include documents longtitle to certain area of the template if, and only if document has something in long title. What's the correct way to check in the template that does the current document actually have a longtitle.

When doing just "<h1>[*longtitle*]</h1>" there will be an empty <h1></h1> if document has no longtitle and the page will have an empty area at the top of the page which just looks stupid..

Can I put php code straight to the template? or do I have to wrap it around php tags? In what point f.ex. [*longtitle*] in the template has been actually converted to the data?

What I'm thinking that can I just do something like: if([*longtitle*] != "" || [*longtitle*] != null)
Or do I have to use the api to first get the current doc and then check if it has something in longtitle? Something like:
$doc = $etomite->getDocument() (but this requires the id of the document, so not actually working like this)
if ($doc['longtitle'] != "" || $doc['longtitle'] != null)...

And do I have to put this check and the return to a snippet, or can I do it straight to the template?

And what's the place to look this kind of basic stuff? I know about the wiki and the api-listing, but could not find this kind of stuff in there.. are there any "tutorials" about making templates/snippets other than the ones that are in wiki?

Thanks! :rolleyes:

#2 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 13 December 2005 - 02:54 AM

Although your logic would appear to be the solution I don't think that it will work due to the method that the Etomite parser actually parses and renders pages... Your logic in the template won't process properly because the requested content has not been processed in the order required for the logic to return the proper response... I discovered this myself while working on document template switching code for my personal site... I ended up creating a snippet that performed the required document checks and use the snippet call in place of [*content*] in my site template...

#3 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 13 December 2005 - 07:42 AM

Check out the PageBeginning snippet in the snippet library. It does what you're trying to do and more.

Best Regards, Lloyd.

#4 doze

    Etomite Forum Fan

  • Member
  • Pip
  • 119 posts

Posted 14 December 2005 - 09:22 PM

lloyd_borrett, on Dec 13 2005, 10:42 AM, said:

Check out the PageBeginning snippet in the snippet library. It does what you're trying to do and more.

Best Regards, Lloyd.

Just saw your snippet today from another thread.. And from your post in there too (the thread about SEO in eto). :D It's just what I was looking for, thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users