Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi,

before posting my question: thanks a lot for the help and keep it up with Couch!

Question...:
- I have a page where I store games (games.php).
- Games has some fields that are empty, some are required.

When showing the page-detail of a game, I load data via an XML API.
I wish to store some of the results of this API call into the game fields.
Is this possible?

It's ok for me that you need to be logged in to perform such action for example...

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

    <cms:template title="Boardgames" clonable="1">
        <cms:editable name="boardgame_id" type="text"/>
        <cms:editable name="boardgame_cover" type="text"/>
        <cms:editable name="boardgame_name" type="text"/>
    </cms:template>

    <cms:php>
        global $xml;
        $xml = simplexml_load_file('https://api.geekdo.com/xmlapi/boardgame/<cms:show boardgame_id/');

        // I WANT TO STORE THIS VALUE TO "boargame_cover"
        echo $xml->boardgame->thumbnail;
    </cms:php>


<?php COUCH::invoke(); ?>


Thanks!
Code: Select all
<cms:php>
    global $xml, $CTX;
    $xml = simplexml_load_file('https://api.geekdo.com/xmlapi/boardgame/<cms:show boardgame_id />');

    $CTX->set('boardgame_cover', $xml->boardgame->thumbnail);
</cms:php>
<cms:show boardgame_cover />


Code example shows storing a PHP variable into a Couch variable. However, saving to a field in backend permanently requires more than just that.
Need assistance? PM or email me.

active topics
Thanks for the answer.

- I do want to store it in the database
- I want it to link to this specific page (k_page_id)...
pellens wrote: Thanks for the answer.

- I do want to store it in the database
- I want it to link to this specific page (k_page_id)...


You'd want to search forum for examples of cms:db_persist tag.. That's the way to post anything to your fields and save to db.
Need assistance? PM or email me.

active topics
4 posts Page 1 of 1

Who is online

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

Users browsing this forum: No registered users and 2 guests