Conditional removal of code

2 views
Skip to first unread message

Infini

unread,
Oct 8, 2010, 11:14:16 AM10/8/10
to Edicy Designer
One one of my layouts, I have created a content area called
"posttitle1".
Coded in a line like this:
<div class="pagetitle"><h2>{% content name="posttitle1" %}</h2></
div>
Works fine...

I would like that, when "posttitle1" is empty, all the complete above
line disappears from the generated code.

I have tried this, but it does not seem to work:
{% if "posttitle1" == empty %}
{% else %}
<div class="pagetitle"><h2>{% content name="posttitle1" %}</h2></
div>
{% endif %}

Hope someone is following this group... Not so much posts!


Thanks for help.


Thomas

Priit

unread,
Oct 8, 2010, 2:32:59 PM10/8/10
to Edicy Designer
Hi Thomas,

At the moment, you cannot build conditions based on presence of a
certain content area. In our practice working on thousands of sites,
this question has popped up only couple of times.

Could you please tell us what you're trying to achieve in a broader
sense. It looks like you need something that can be solved with blog
or elements. "Elements" is a feature that is currently in private-beta
testing. It let's you build objects with custom fields and it works
almost the same way as blogging, only you can define the object data
structure by yourself.

Maybe this will work for you, let us know if you're interested and
we'll enable this feature for the site you're working on.

Cheers,
Priit.

Priit

unread,
Oct 8, 2010, 6:42:15 PM10/8/10
to Edicy Designer
Hi all! Just to get your minds flowing, i'd like to give you a brief
introduction, what the "Elements" are in Edicy and what they can do.

As i said in a previous message, one can define custom objects with
fields that user can later fill these in to create objects. These
objects can be later searched, filtered or sorted in page template.

I'll start with a brief example. Lets say that we want to add a list
of books to the site. In Edicy, there is an option to define object
"Book" with it's attributes, for example:

* Title
* Author
* ISBN
* Cover photo
* Description
* Genre

Now let's imagine that user has already entered some books on the
site. To list all books, the page template may look like this:

<!-- Render the list of books on page -->
{% for book in elements %}
<div class="book">
<h2><a href="{{ book.url }}">{{ book.title }}</a></h2>
<p>{{ book.author }} - {{ book.isbn }}</p>
<img src="{{ book.cover_photo }}" alt="" />
</div>
{% endfor %}

A special variable named "elements" is available on page that is
marked as elements page (it can be specified in page template type).
This variable contains a list of elements associated with this page.
There can be multiple pages containing different objects or even
objects of different types (e.g "Book" and "Magazine").

Each object has its own page with its own url (notice the
{{ book.url }} property). To this page you can create another
template, that displays the information only for the given book. On
this page, a special variable called "element" is available.

<!-- Render the title and description for selected book -->
<h2>{{ element.title }}</h2>
<div class="genre">{{ element.genre }}</div>
<div class="description">{{ element.description }}</div>

On any other page, elements can be loaded through special {%
elementscontext %} block, where the special "elements" variable is
available. Additional attributes can be provided in the block tag,
which filter the elements to be assigned inside the block:

<!-- Render only the fiction books -->
{% elementscontext genre="Fiction" %}
{% for book in elements %}
<h2><a href="{{ book.url }}">{{ book.title }}</a></h2>
{% endfor %}
{% endelementscontext %}

This "Elements" feature works well for certain scenarios -- usually
for sites where one might want to have a simple database of things
that must be listed on site and nothing more. It does not attempt to
replace databases or applications that are more complex than that.

I'd like to end this message with a real-life example of lawyer firm
site http://www.varul.com This site is built using several different
object types -- notice the "Publications", "Practices" and "People"
sections. These listings are being built with elements. Also notice
that publications are associated with people and practices.
Associations can be created between different kind of objects, however
this is something that is in very early beta stage.

I hope you find this overview useful and if you have any questions,
please do not hesitate to ask.

Best,
Priit Haamer
Edicy.

Infini

unread,
Oct 12, 2010, 9:38:34 AM10/12/10
to Edicy Designer
Tks for answer & noted.

I need a few days before answering...

Tks
Reply all
Reply to author
Forward
0 new messages