Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi,

I'm wondering how to accomplish the following .

I have a sales.php template and a companies.php template with a relation in the sales template
Code: Select all
<cms:editable type='relation' name='company' masterpage='companies.php' has='one' />


I like to produce a list of companies that has a sales relation…
Code: Select all
<cms:pages folder='open-invoices' include_subfolders='1' masterpage='sales.php' >

<cms:if "<cms:related_pages 'company' count_only='1' />" >
<cms:related_pages 'company' masterpage='companies.php'>
<cms:show k_page_title />
</cms:related_pages>
</cms:if>

</cms:pages>


The problem I can't solve on the moment is, when a company has more than one relation this one would be displayed more the one times. How do I filter the list so that the related company only shows up once ?
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hi Tom,

Your code is actually listing all 'sales' pages and, while displaying a page, it also displays the related 'company', if any.

What you actually wish to do is list all 'company' pages that have at least one sales related to them. Right?
I like to produce a list of companies that has a sales relation

To do that, you'll have to upgrade to Couch1.4.5RC and then you can simply use cms:pages to list the company pages as follows -
Code: Select all
<cms:pages masterpage='companies.php' custom_field="sales.php::company=ANY"  >
    <a href="<cms:show k_page_link />"><h3><cms:show k_page_title /></h3></a>
</cms:pages>

The code above fetches only those company pages that have the 'company' custom_field of sales.php related to it.

You can learn more about this Enhanced cms:pages tag at viewtopic.php?f=5&t=8581

Does it help?
Thanks KK

That's what I was looking for. I was reading this morning about the Enhanced cms:pages tag and tried some options but couldn't get this to work because I totally missed there was possibility to use ANY. :oops:

thanks again
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
I suppose it's not possible but I had to ask ...

Is there any chance to filter on a field of the related page in the Enhanced cms:pages tag ?

Let's say postcode from the companies pages e.g. custom_field="sales.php::company=ANY && postcode= '2906'"
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Since the 'masterpage' parameter of cms:pages points to 'companies.php' -
<cms:pages masterpage='companies.php' ..
you can use regions defined in companies.php in the 'custom_field' parameter as usual. We cannot (yet) use regions defined in the other template (i.e. sales.php) except the 'relation' types, as we have done in the example.

So, if the 'postcode' is defined in 'companies.php', you can add it to the mix by using the pipe '| separator -
<cms:pages masterpage='companies.php' custom_field="sales.php::company=ANY | postcode='xxxxx' " >

If, however, the 'postcode' is defined in 'sales.php', I'm afraid it won't be possible.

Hope it helps.
If, however, the 'postcode' is defined in 'sales.php', I'm afraid it won't be possible.

I was looking for this option.


Thanks for to make it more clear for me.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
6 posts Page 1 of 1