Problems, need help? Have a tip or advice? Post it here.
14 posts Page 2 of 2
Hi roshea89,

That ultimately is for you to decide. Updating 20-30 items is not a big deal and you can certainly do it if your use-case requires it. However, I was wondering why would you want to do that at each page load? Even querying Amazon API at each page load would be something you should take another look at and reconsider.
Hey KK,

Amazon API should be fine, i only make 1 call to it on each page load via providing an array of all the items i want to look up.

My only concern was the possible 20-30 database hits via the db_persit tag on each page load - but so far it seems to be handling it fine.

I will be caching the pages when i put it live, so should only have to call the amazon api and update the items in couch once and then serve the cached paged for say 24 hours.

Only reason i want to do it this was is so the site is always updated with if the item is in stock and what options are available etc, but a 24 hour delay should be fine when i cache the pages.
This saved me today, thank you.

KK wrote: $tag = 'cms:db_persist';

$html =<<<EOS
<$tag
_masterpage=k_template_name
_page_id='$itemId'
_mode='edit'

my_textarea='Out Of Stockx-$itemId'
/>
EOS;

$FUNCS->embed( $html, $is_code=1 );
@Blutbaden, there is a non-php version which uses strings. CouchCMS doesn't run its tags if they are enclosed in single quotes and are, essentially, a string parameter as described in docs.
Code: Select all
<cms:set code = "<cms:concat
                p1='<cms:db_persist _masterpage=target_template _mode=\'edit\' _page_id = k_page_id '
                p2="<cms:show target_editable /> = value >"
                p3='<cms:if k_error><cms:dump /><cms:else_if k_success /><cms:show k_page_title /> - OK </cms:if></cms:db_persist>'
                />" />
<cms:embed code=code ></cms:embed>
14 posts Page 2 of 2