Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
I want to change image on my site but when i upload an image and save it, the image doesn't appear, it just show the link to image.

I have this code:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Domaca stran (index.php)'>
</cms:template>
<cms:editable name='logo_slika'
   crop='1'
    width='531'
    height='206'
    type='image'
/>

<a href="http://www.avtoteka.si/index.php"><img src="<cms:show logo_slika />" alt="logo" id="logoslika" ></a>

<?php COUCH::invoke(); ?>
Hi and welcome, siter :)

You have defined the image editable region outside the cms:template block. Please rectify the code to make it as follows.
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
    <cms:template title='Domaca stran (index.php)'>

        <cms:editable name='logo_slika'
           crop='1'
            width='531'
            height='206'
            type='image'
        />

    </cms:template>


    <a href="http://www.avtoteka.si/index.php"><img src="<cms:show logo_slika />" alt="logo" id="logoslika" ></a>

<?php COUCH::invoke(); ?>
As you can see, I've moved the cms:editable definition to within the <cms:template>..</cms:template> tag pair.

This should prevent the link of the image from appearing on the page.

Rest of you code seems to be correct so
Code: Select all
<img src="<cms:show logo_slika />" />
should work fine.

Please try it and let us know.
Thanks.
I changed the code and the image still doesnt show. But now the link to image doesnt appear.
OK, it could be a permission issue.
To verify please add the highlighted lines to the image's definition
<cms:editable
name='logo_slika'
crop='1'
width='531'
height='206'
show_preview='1'
preview_width='200'

type='image'
/>
Refresh the template by visiting as super-admin for the change to get picked up by Couch.

Coming back to the admin-panel, try uploading a new image. If it gets uploaded, the image should appear in the preview.

If not, please make sure the folder where the images get uploaded to (by default it 'couch/uploads/image') has write permissions - try with 755 and go on to 777.

Hope this helps.
i have tried and copied the image tag somewhere else on page and it worked.

Maybe it is problem in the image tag in html/php file:

Code: Select all
<div id="wrapper">
    <div id="logotip">
    <cms:editable name='slika_logo_s_podnapisom' type='richtext'>
       <a href="http://www.avtoteka.si/index.php"><img src="<cms:show logo_slika />" alt="logo" id="logoslika" ></a>
      </br> <div class="textToChange"> <span id="napis">Avtoteka, vaš servis, zanesljiv partner za vaš avtomobil</span></div>
      </cms:editable>
    </div>


EDIT:
ahhhh now i see it. i already have a cms tag for the picture. If i remove it picture loads fine.

Thanks anyway :)
I have another problem. I have a javascript for changing images and when i upload a image to this script, script doesn't work.

code of script:

Code: Select all
<div id='right_menu'>
   
      <script type="text/javascript">
    
    
    
<!--
//preload images
var image1=new Image()
image1.src="<cms:show novice_slika />"
var image2=new Image()
image2.src="<cms:show novice_slika2 />"
var image3=new Image()
image3.src="<cms:show novice_slika3 />"
//-->
      </script>
     
     
      <a href="javascript:slidelink()"></br>
        <img src="<cms:show novice_slika />" width="250" height="240" id="slide2" border="1" /></a>
      <script type="text/javascript">
  var name2 = "#right_menu";
  var menuYloc2 = null;
 
    $(document).ready(function(){
      menuYloc2 = parseInt($(name2).css("top").substring(0,$(name2).css("top").indexOf("px")))
      $(window).scroll(function () {
        offset = menuYloc2+$(document).scrollTop()+"px";
        $(name2).animate({top:offset},{duration:400,queue:false});
      });
    });
      </script>
      <cms:editable name='novice_slike_povezave' type='richtext'>
      <script type="text/javascript">

var step2=1
var whichimage2=1
function slideit(){

if (!document.images)
return
document.images.slide2.src=eval("image"+step2+".src")
whichimage2=step2
if (step2<3)
step2++
else
step2=1
setTimeout("slideit()",2500)
}

slideit()
function slidelink(){
if (whichimage2==1)

window.location="http://www.avtoteka.si/index.php"
else if (whichimage==2)
window.location="http://www.avtoteka.si/index.php"
else if (whichimage==3)
window.location="http://www.avtoteka.si/index.php"
}

      </script>
      </cms:editable>
    </div>
I see you have put a full JavaScript block with an editable region.
Are you sure you want the end user to be able to edit your JS code?

If for some reason that is precisely what you wish to do, don't use an editable region of type 'richtext'. That'll 'sanitize' all JS.
Use a region of type 'textarea' and set its 'no_xss_check' parameter to '1' e.g.
Code: Select all
<cms:editable name='novice_slike_povezave'  no_xss_check='1' type='textarea'>

Make sure to delete the previously entered content from the region as it would have been sanitized.

That said, I must ask you to please rethink your decision of making the JS code editable. It is a sure recipe for disaster.
Thanks for the solution. I just want that user can change the bottom part with window.location links. They are links, so when you click on image you are redirected to some site. But i must add whole script in tag.
I just want that user can change the bottom part with window.location links. They are links, so when you click on image you are redirected to some site. But i must add whole script in tag.
If it is only parts of the script that the user will change, you should make only those parts editable.

Your original code is -
Code: Select all
if (whichimage2==1)
    window.location="http://www.avtoteka.si/index.php"
else if (whichimage==2)
    window.location="http://www.avtoteka.si/index.php"
else if (whichimage==3)
    window.location="http://www.avtoteka.si/index.php"
}

- It shows the three links you are interested in.

Define three editable regions for these links -
Code: Select all
<cms:editable name='link1' label='Location 1' type='text' />
<cms:editable name='link2' label='Location 2' type='text' />
<cms:editable name='link3' label='Location 3' type='text' />

And now amend the code to show contents of the regions we defined above -
Code: Select all
if (whichimage2==1)
    window.location="<cms:show link1 />"
else if (whichimage==2)
    window.location="<cms:show link2 />"
else if (whichimage==3)
    window.location="<cms:show link3 />"

Hope this clears up how Couch should be used optimally.
Thanks, this works.
11 posts Page 1 of 2
cron