Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
So, I have a unique situation and I'm wondering if someone might have a solution for this. I've been searching around the forums but haven't stumbled upon what might be causing the issue.

I'm working on a dealership website for a client and I'm using couch as the CMS. I love how easy it is to take static designs and make them dynamic with just a few tags thrown here and there. :D The problem I'm running into is that, as a dealership, the client needs to display car information which is taken from a 3rd party database not managed by myself or the dealer.

Now, I've already written a php addon which will call up the database, get the needed info, and return it as a valid JSON object. I then set it to a page variable using the following:

Code: Select all
<cms:set brand="<cms:brand id="<cms:show brand_id/>"/>" is_json='1'/>


<cms:brand> is the tag that accesses the database and returns the JSON object, and <cms:show brand_id/> is just an editable field that we hold the brand ID (a number) in. Then around the page I call those bits of JSON with:

Code: Select all
<cms:show brand.brand_name/>
<cms:show brand.logo/>
<cms:show brand.trim/>


or anything else I have stored using the dot notation.

Everything works just fine for Super Admins and Admins, but for anyone not logged in as an Admin, nothing is shown. On other pages I've pulled single items and returned html strings using this exact same method and it works for everyone, admins and users alike. It's only these couple, more complicated pages where I could use an array that it suddenly falls apart.

I really hate to have to call the database for each piece of info separately. It's much nicer to just call it once, get the 18+ strings, throw them into a JSON object and then call them where they are needed in the nested page with the dot syntax.

Any suggestions? :?:
Hi,

Could you please test the output of just the <cms:brand> tag? i.e. don't set it as variable; rather just print it out e.g. as follows -
Code: Select all
<cms:brand id="<cms:show brand_id/>"/>

Do you see the same problem with it or does the output appear for both admins and anonymous visitors?

Please let me know.
Using just the tag:

Code: Select all
<cms:brand id="<cms:show brand_id/>"/>


outputs for both users and admins alike.

Also, I forgot to mention this, but I'm on 2.1beta (grabbed from GitHub). I did confirm the version with cms:dump as well.
Can I have a look at the site?
Please PM me the FTP+Couch creds (with exact directions on where and how to elicit the problem) if that is possible?

Thanks.
Thanks for the creds.

I had a look and I think I can see the cause -
in the problem template, you have placed some crucial code (sets up some variables later used in JSON) *within* <cms:template> tag block.

Now, this block executes only for super-admins (as it is supposed to contain only code defining editable regions etc.) so the code works when a super-admin is logged in. For normal users, no <cms:template> and so setting of your variables.

Please move that code out from the cms:template block and that should solve the problem.

Hope this helps.
That was exactly it! Once I moved that bit of code 1 line down so it's out of the template area, that solved the whole thing!

Thank you so much.
6 posts Page 1 of 1
cron