Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
So, I've got a custom photo gallery set up. The following is the code.

Code: Select all
<div class="gallery1">
               <ul>
                   
                    <cms:pages masterpage='gallery/page_gallery.php'>
                    <li>
                                                <a href="<cms:show k_page_link />">                         
                        <span><cms:show k_page_title /><br></span>
                                <img src="<cms:show gallery_image />" alt="" width="230" height="230">
                     </a>
                         
                           
                            <a href="#!/<cms:show k_page_link />">
                        <span><cms:show k_page_title /><br></span>
                                <img src="<cms:show gallery_image />" alt="" width="230" height="230">
                            </a>
                           
                    </li>
                    </cms:pages>
               </ul>
            </div>


This displays a two x infinitely long, scrolling, js-based image gallery. See the old, non-Couch version here: http://trezurehunt.in/

With the above code, I more or less manage to re-do gallery, but there are a couple of obvious errors. See http://trezurehunt.in/test/ to see what I mean.

Now, I know that I'm calling the same functions twice, in both 'a' elements, but that's what my existing hard coded gallery was, multiple 'li' columns of 2 'a' elements each.

Basically, I'm thinking of the masterpage codes as 'for' loops in their most basic essence. So I'm wondering if there's a way to store a counter, display 2 elements, update the counter, recursively call the next set. Unto infinity.

Also, it's taken me barely an hour to get to wherever I've gotten, so I'm happy enough to be completely open to any other ways of doing this too. :D

Cheers.
It's a bit difficult to understand what the problem is because both links are not working at the moment.

Try this though:
Code: Select all
<div class="gallery1">
<ul>
<cms:pages masterpage='gallery/page_gallery.php'>
   <cms:if "<cms:mod k_current_record '2' />" >
      <li>
   </cms:if>
      <a href="<cms:show k_page_link />">                         
      <span><cms:show k_page_title /><br></span>
      <img src="<cms:show gallery_image />" alt="" width="230" height="230"></a>
   <cms:if k_current_record = k_total_records || "<cms:sub "<cms:mod k_current_record '2' />" '1' />" >
      </li>
   </cms:if>
</cms:pages>
</ul>
</div>
Hopefully that's what you wanted. :| The idea is to only show the opening <li> if on an odd iteration and to only show the closing </li> if on an even iteration or the last iteration.
Wow, that worked like a charm!! :D I didn't think of using an if statement so creatively. :P

But onto the more important issue, why are the links not opening at your end? I realise that the test link isn't working because I haven't linked up a database to it yet, but just http://www.trezurehunt.in should be working like a charm. :S

Either way, thanks a ton. I bow before your thine wisdom.
I'm glad it worked. :D

When I visit the website I get redirected to http://www.trezurehunt.in/cgi-sys/defaultwebpage.cgi. Have you made any DNS changes lately? Perhaps they have not reached me yet...
Ah well, that should sort itself out in the next couple of days.

I've hit another little snag.

I've got a one-page website which revolves around the gallery. When a gallery image is clicked on, a 'popup' launches over the middle of the page and displayed some information about the image.

I'm having some trouble with embedding dynamically generated 'page-views' pages into these pop-up containers.

I decided that since there seem to be DNS problems, my paint skills would need to come into play, so here are some images explaining things. I'm also attaching my index.php (http://db.tt/Sch0BdGx)

Image 1: The General Layout of the Site
Image

Image 2: When an image is clicked, it is supposed to pop-up into a container like below
Image

Image 3: But, this doesn't seem to be happening. :S See lines 86-96, 115-120. Line 117's embed function is definitely called, but I don't seem to be able to "pull" the html content from any of the pages. Note: Direct links using <cms:show k_page_link> in line 90 does redirect to the correct html page, I just want to pull this page and embed it into the list items in lines 115-120.
Image

Image 4: Conversely, the non-dynamically generated snippet for the About Us and Contacts pages works well.
Image

So, I'm at a bit of a loss. Hopefully someone can figure out and let me know what's going wrong/whether what I'm doing is even possible with CouchCMS.

:)

Cheers,
Hi,

Line 117
Code: Select all
<cms:embed '<cms:show k_page_link/>' />

Make it
Code: Select all
<cms:embed "<cms:show k_page_link/>" />

i.e. change the 'single-quotes' to 'double-quotes'.
The "double-quotes" are needed for Couch to treat the enclosed parameter as another Couch statement and actually execute it to get a value. Single quotes will only make it treat the parameter as a simple string (please see http://www.couchcms.com/docs/concepts/s ... eters.html).

As an aside, you could have alternatively coded the statement simply this way-
Code: Select all
<cms:embed k_page_link />

No quotes mean the parameter is a variable (which it actually is in this case)

Hope this helps. Do let us know.
Hi KK,

I did as you asked, and changed the parameter to double apostrophes, but now I get the following error whenever I click on any image.

error embedding file: W:/www/couch/snippets/http://localhost:8080/gallery/page_gallery.php?p=X

X corresponds to the id of the image clicked on.

I see that the link it's trying to embed is expected to be relative to the snippets folder, but the k_page_link variable stores a more absolute address.

Will moving the page_gallery.php to the snippets folder help? page_gallery.php is a template containing details of each gallery item, but I'm not planning on using that page, per se.

edit: the error appears in the correct position, on top of the gallery items, so hopefully it's an easy tweak.
OK, I should have taken a closer look as to what you were trying to achieve.

Here is your original code:
Code: Select all
<cms:pages masterpage='gallery/page_gallery.php'>
   <li id=<cms:show k_page_name/>
      <cms:embed "<cms:show k_page_link/>" />
   </li>
</cms:pages>

Now, cms:embed tag is used to read in *physical* files present within 'couch/snippets' folder and then output their contents.
In your case you are actually trying to embed a URL - which of course won't work.

What you are trying to do is output the contents of the cloned pages. That can be easily done this way -
You must have defined several editable regions within 'gallery/page_gallery.php'. I don't know their names so I'll assume there are two - 'my_image' and 'my_desc'.
As we loop through the cloned pages using the cms:pages, Couch makes available the content of the pages through variables of the same name as the editable regions. So if we modify your snippet to the following, we'll get the contents of each page
Code: Select all
<cms:pages masterpage='gallery/page_gallery.php'>
   <li id="<cms:show k_page_name />">
      <h1><cms:show k_page_title /></h1>
      <img src="<cms:show my_image />" />
      <div>
         <cms:show my_desc />
      </div>
   </li>
</cms:pages>

Try it out by replacing the variable names with that of your own regions.
I fixed a few additional problems. I suspect the "./index.html" and "#!/page_home" linking might be incorrect nevertheless. It's hard for me to tell how this is supposed to work without seeing the live example including the JavaScript.
Wow! I love how quickly you guys reply back!

So, thanks KK, I tried doing that earlier too, but it was "showing" the same result, and it wasn't until I ran a DOM inspector that I realised that two different things were happening.

The url linking was displaying the cannot embed error, but I couldn't see it. This was caused by the missing couplet of code:

Code: Select all
<li id=<cms:show k_page_name />>

<div class="box"> </div>

...
</li>


Simply placing the box div at the beginning of every list element created the actual box, "revealed" it, and put in the animations to open/close the box.

I stupidly deleted it thinking it's an empty div, not realizing that the css and js were pulling the strings.

It now works! Brilliantly! Yay! I've finally transferred a working version of the website onto CouchCMS. And without this little snag, it literally took just about 4 hours including reading up on the (very easy to read) documentation.

Now to use some editable regions to make the whole website as extensible as possible!

@Cheesypoof thanks for spotting the html leftovers in the footer. The "#!/page_home" linking does work though because what it refers to in an empty list element, thus calling the JS to clear out the page.

Basically, all my "pages" are actually list elements with ids that begin with "#!/". What "#!" does it that it creates a relevant path.

So if you're on http://www.google.com/index.php and you click on a link that says: "#!/superman", you will be redirected to http://www.google.com/index.php#!/superman

This doesn't refresh the page, allowing you to use javascript (and apparently html5/CSS3) in order to do wacky things with the page.

Hope it clears things up! Thank you for dredging through my code and cleaning it up a bit. You can check out the website at [url]trezurehunt.in[/url] as soon as it's complete. :D

I'd like to add that CouchCMS is easier to pick up than ANY other CMS I've used. All in all, very nice experience. :)
12 posts Page 1 of 2
cron