Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Hi, i was wondering is there any way for code like this to work:
<cms:link masterpage='something.php' folder='news' limit='1'/>

I need something like that because i have one template where 'a' tag has nested elements and i can't use cms:pages becuse it repeats the whole a tag with its content.

I want to directly link from href, but with the ability to limit news posts.
Hi,

The cms:link tag simply outputs the canonical URL of the indicated page taking into consideration whether prettyURLs are turned on or not. So the limit thing you are mentioning really doesn't fit into it.

Could you please post in the exact code (the 'a' tag with nested elements) where you are trying to use the link tag?
Maybe there exists a better solution.
Hi,

I'm not completely sure what you mean, but why wouldn't the code below work?
Code: Select all
<cms:pages masterpage='something.php' folder='news' limit='1'>
     <a href="<cms:show k_page_link />"><cms:show k_page_name /> {or just text}</a>
</
cms:pages> 


You just add the <cms:pages> tags around the part where the link is in, and you use <cms:show k_page_link /> for echo'ing the last page/article.

Anyhow, there is no 'limit' paramter in the <cms:link> tag (*click*). ;)


Edit: Oh, ninja'd by KK :)
Sincerely,
Johan

Brightsites
Webdesign, webdevelopment, webapplications, hosting, advice and more.
Here is the code:
<cms:pages masterpage='obavijest.php' folder='nalozi' limit='8'>
<a class="newsLink" href="<cms:show k_page_link/>">
<h1 class="naslov ">Nalozi</h1>
<img alt="" src="images/pic3.png" />
</a>
</cms:pages>

Silly me, of course this code doesn't work, i don't need 8 links, i need the output to have 8 news posts.I need the output of the href to display news posts in particular category and to limit it to certain number.
Maybe i should try something with folders tag?

p.s. Those funny words in the code are croatian words!
p.p.s. Maybe to rephrase my question, in the tutorial some categories are created in the sidebar, when clicking on them they show all the posts belonging to category, how to limit the number of posts shown.I think this will solve my problem.
Hi,

I still don't think I get you completely. Maybe we are missing something very very basic here..
i don't need 8 links, i need the output to have 8 news posts

OK - Let us suppose your 'obavijest.php' has two editable regions - one richtext (say named 'my_content') and another image (say named 'my_image')
The following code displays the titles and images of the latest 8 items from the template -
Code: Select all
<cms:pages masterpage='obavijest.php' folder='nalozi' limit='8'>
        <h1 class="naslov "><cms:show k_page_title /></h1>
        <img alt="" src="<cms:show my_image/>" />
</cms:pages>

If you wish you can additionally display the 'my_content' also (and any other editable region defined for the template) e.g.-
Code: Select all
<cms:pages masterpage='obavijest.php' folder='nalozi' limit='8'>
        <h1 class="naslov "><cms:show k_page_title /></h1>
        <img alt="" src="<cms:show my_image/>" />
        <div>
             <cms:show my_content />
        </div>
</cms:pages>

I need the output of the href to display news posts in particular category

The output of an href is always a link that will open up a new page e.g.
if we wrap the title (or image) with anchor tag this way -
Code: Select all
<cms:pages masterpage='obavijest.php' folder='nalozi' limit='8'>
        <a class="newsLink" href="<cms:show k_page_link/>">
                <h1 class="naslov "><cms:show k_page_title /></h1>
        </a>
        <img alt="" src="<cms:show my_image/>" />
</cms:pages>

- clicking on the title will open up the page-view showing the news item in full.

This is how we generally handle listing of cloned pages.
Please let me know how different is it from what you wish to get done.
I will try to be as simpler as i can this time, let's say i have 3 categories(folders), and i want to show only one category and have a limit on number of posts shown.
I want to use an ordinary a tag to do this, if i enclose it with cms:pages i get repeated links in my layout, and i don't want that.
I want to be able to show what i want through one link.
madebym wrote: clicking on the title will open up the page-view showing the news item in full.
Ok, but it will also ruin my layout by creating more links, and i want just one.

Please, i think this question is the answer to my problems:
In the tutorial some categories are created in the sidebar, when clicking on them they show all the posts belonging to category, how to limit the number of posts shown.I think this will solve my problem.
In the tutorial some categories are created in the sidebar, when clicking on them they show all the posts belonging to category, how to limit the number of posts shown.I think this will solve my problem.

You have mentioned the way categories are listed in the sidebar of our tutorial.
Let us start from there.
In the tutorial the code is
Code: Select all
<h4>Categories</h4>
<ul class="sidebar">
   <cms:folders masterpage='blog.php' >
      <li><a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a></li>
   </cms:folders>
</ul>

Suppose 'blog.php' had 2 categories 'cat1' & 'cat2'. The code above would result in the following with prettyURLs turned on
Code: Select all
<h4>Categories</h4>
<ul class="sidebar">
   <li><a href="http://www.yoursite.com/blog/cat1/">cat1</a></li>
   <li><a href="http://www.yoursite.com/blog/cat2/">cat2</a></li>
</ul>

Without prettyURLs, it would be -
Code: Select all
<h4>Categories</h4>
<ul class="sidebar">
   <li><a href="http://www.yoursite.com/blog.php?f=1">cat1</a></li>
   <li><a href="http://www.yoursite.com/blog.php?f=2">cat2</a></li>
</ul>

Point to note is that the links
Code: Select all
http://www.yoursite.com/blog/cat1/
or
http://www.yoursite.com/blog.php?f=1

when clicked will lead back to 'blog.php'.

Instead of using cms:folders tag to create the folder-view URLs, we can use the cms:link tag to do the same (if we know the folder names) e.g. the following will generate the same code
Code: Select all
<a href="<cms:link masterpage='blog.php' folder='cat1' />">cat1</a>

Once someone clicks on the links and 'blog.php' gets called, it is now upto our code within it to list pages however we like.
We can be helped by the fact that Couch is smart enough to figure out by seeing the 'f=1' or 'cat1' in the URL that this is the 'folder-view' and makes available information about the folder in question for you to handle. This it does by setting up certain variables - k_folder_name being one of them e.g. if the link clicked was for folder 'cat1', k_folder_name will contain 'cat1' as value.

In our case, what we can do is check whether it is the folder-view we are handling (i.e. the link bringing up blog.php had folder info within it) -
Code: Select all
<cms:if k_is_folder >

</cms:if>

If it is, we can then list the pages belonging to the folder -
Code: Select all
<cms:if k_is_folder >
   <cms:pages masterpage='blog.php' folder=k_folder_name>
      <h1><cms:show k_page_title /></h1>
      ...other variables of each page in the folder..
   </cms:pages>
</cms:if>

Notice how we have set the folder=k_folder_name where k_folder_name will be either 'cat1' or 'cat2' depending on the link clicked.

The code above will list all the pages belonging to the folder being listed.
Since you require only 8, we can set the limit parameter -
Code: Select all
<cms:if k_is_folder >
   <cms:pages masterpage='blog.php' folder=k_folder_name limit='8'>
      <h1><cms:show k_page_title /></h1>
      ...other variables of each page in the folder..
   </cms:pages>
</cms:if>

This is the only way we can list pages in Couch.
Do let me know if this helped.
Thanks.
KK wrote: Once someone clicks on the links and 'blog.php' gets called, it is now upto our code within it to list pages however we like.


I got it all now, everything i needed you said in one sentence.
Thanks.
You are welcome :)
9 posts Page 1 of 1

Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 15 guests