Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
I want to add only new image on my site, while text_1, text_2, text_3, text_4 need to stay unchanged. But here is the problem, if I upload the new image, and don't fill text_1,2,3,4 on page they will be empty and the new image will be there. Here is my admin panel:
http://i.imgur.com/jLtX9hO.png

This is the code I'm currently using.

Code: Select all
<cms:template title="Home" clonable="1" commentable="0">                  
<cms:editable name='text_1' type='richtext'/>
<cms:editable name='text_2' type='richtext'/>
<cms:editable name='img' type='image'/>
<cms:editable name='text_3' type='richtext'/>
<cms:editable name='text_4' type='richtext'/>
</cms:template>



<cms:pages limit='0'>
<div class="intro-item" style="background-image: url(<cms:show img/>);">
<div class="caption">
<h2><cms:show text_1/></h2>
<p><cms:show text_2/></p>
<a class="button white transparent" href="contact.html">Contact</a>
</div>               
</div>
</cms:pages>



<cms:pages limit='0'>
<div class="quote">
<p>"<cms:show text_3/>"</p>
<div class="author"><cms:show text_4/></div>
</div>
</cms:pages>
Hi,

if I upload the new image, and don't fill text_1,2,3,4 on page they will be empty and the new image will be there.
I'll assume that before you uploaded the image, the text regions had some existing content which were lost when the image was uploaded. Right?

If so, this not the normal behaviour and perhaps has something to do with your setup which, I take, is still on your local machine.

Since your setup is not yet accessible online, I'm afraid there is little I'd be able to do to help you with this issue.

I can only suggest you please migrate your site to a properly hosted test domain. Chances are that you won't encounter such issues there. And if you do, I'll be able to access the setup to help in a more meaningful way.

Thanks.
It doesn't matter if it's image or text. For example here I uploaded only text_3,4 but CMS added image code also:

Code: Select all
<div class="intro-item" style="background-image: url();">
<div class="caption">
<h2></h2>
<p></p>
<a class="button white transparent" href="contact.html">Naruči</a>
</div>               
</div>


All field are empty the same thing happens if I only add image:
Code: Select all
<div class="quote">
<p>""</p>
<div class="author"></div>
</div>
OK, I think I'll have to revise my understanding of the problem you are trying to convey.
Which now seems to be this -

You are displaying an editable region on the template as follows
Code: Select all
<h2><cms:show text_1/></h2>

When there is no content within the region, the code outputted becomes this -
Code: Select all
<h2></h2>

You want the <h2></h2> outputted only if there is the editable region is not empty.

Did I get it right this time?

If so, the solution is to first check yourself if the region is not empty and then output the markup related to it. For the example above, the code would become -
Code: Select all
<cms:if text_1>
   <h2><cms:show text_1/></h2>
</cms:if>

For richtext regions we'd need to use cms:not_empty to do the check (as richtext can contain invisible markup) -
Code: Select all
<cms:if "<cms:not_empty text_1 />" >
   <h2><cms:show text_1/></h2>
</cms:if>

As a fuller example, for a code such as the following -
Code: Select all
<div class="intro-item" style="background-image: url(<cms:show img/>);">
    <h2><cms:show text_1/></h2>
    <p><cms:show text_2/></p>
</div>

You'll have to use this to conditionally show the regions -
Code: Select all
<div class="intro-item" <cms:if img >style="background-image: url(<cms:show img/>);"</cms:if>>
    <cms:if "<cms:not_empty text_1 />" >
        <h2><cms:show text_1/></h2>
    </cms:if>

    <cms:if "<cms:not_empty text_2 />" >
        <p><cms:show text_2/></p>
    </cms:if>
</div>

The purpose of this code is to show you the required technique. I'm sure you'll be able to adapt it to your needs.

Hope it helps.
That was exactly what I meant! Love this CMS, tnx man! :D
I'm glad it helped :)
6 posts Page 1 of 1