Problems, need help? Have a tip or advice? Post it here.
18 posts Page 2 of 2
The displayed url looks fine. Try to copy it to browser and see if image can be loaded.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
The url is fine... loads the image in the browser but the trouble is that the front end is in Android and not on web

Android demands absolute path of the image to display the image.
Image
where innovation meets technology
skype suddenly started to update itself
and has become unresponsive
Image
where innovation meets technology
Place that file to snippets.
Now the usage:
Code: Select all
<cms:pages masterpage='company.php' skip_custom_fields='1' >                

    <cms:set s_fieldname = 'firmalogo' />
    <cms:set s_link = "<cms:embed 'securefile_link.html' />" />

    <cms:if s_link >
        <img src="<cms:show s_link />"  />
    </cms:if>

</cms:pages>

s_fieldname - name of your securefile editable

In that snippet, Line#35 you can remove this line <cms:cloak_url securefile_fullpath />
And just make it <cms:show securefile_fullpath />
Then it should work as expected.

Attachments

Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Awesome Bro...

This is the final code that got me all the outputs needed:

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

   {
   "notices" :
   [
      <cms:pages masterpage='add-notices.php' skip_custom_fields='0'>
      {
            "noticesImage" :  "<cms:set s_fieldname = 'notices_image' /><cms:set s_link = "<cms:embed 'securefile_link.html' />" /><cms:if s_link ><cms:show s_link /></cms:if>",            
            "noticesTitle" :  "<cms:show notices_title />",
            "noticesContent" :  "<cms:addslashes><cms:show notices_content /></cms:addslashes>",
            "noticesDate" :  "<cms:addslashes><cms:show notices_date /></cms:addslashes>"
      }<cms:if "<cms:not k_paginated_bottom/>">,</cms:if>
      </cms:pages>
   ]
}
<?php COUCH::invoke(); ?>


I didn't go in for the
Code: Select all
echo(json_encode($jsonFeed));


method here that you pointed as all other JSON are generated in the above manner.

I will now test it in the Android app too in a jiffy!!!
Image
where innovation meets technology
Code: Select all
<cms:set s_fieldname = 'notices_image' />

Above code i'd place outside for clarity. No need to have it set on each iteration again and again?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Ok I tested the new JSON online:HERE

And here is the problem. The output is:
Code: Select all
 "noticesImage": "/home/genxcode/public_html/demo/TDirectory/uploads/attachments/acde3b4477427b3cb961cd5cbfd155b9.png"


Where as the expected output should be:
Code: Select all
http://www.sitename.com/couch/uploads/attachments/acde3b4477427b3cb961cd5cbfd155b9.png


On the localhost it works fine and outputs what is required in the format:
Code: Select all
"noticesImage": "E:/wamp/www/TDCouch2/couch/uploads/attachments/acde3b4477427b3cb961cd5cbfd155b9.png"


So when I test it with localhost, the output is fine on the app. But the moment i shift to the server, the application breaks as it cannot get a easy to read JSON value in the key:value pair.

Any suggestions?
Image
where innovation meets technology
trendoman wrote:
Code: Select all
<cms:set s_fieldname = 'notices_image' />

Above code i'd place outside for clarity. No need to have it set on each iteration again and again?


So do you mean that i can just use
Code: Select all
<cms:set s_link = "<cms:embed 'securefile_link.html' />" /><cms:if s_link ><cms:show s_link /></cms:if>

without the
Code: Select all
<cms:set s_fieldname = 'notices_image' />


coz if i remove it, it shows me the following on the browser window:
Code: Select all
Variable <i>s_fieldname</i> is required to fetch securefile field. <br/><br/>
                  Sample: <pre>&lt;cms:set s_fieldname = \'notices_image\' /></pre>
                  <br/>
                  Example:
                  <pre>
                  &lt;cms:pages masterpage=\'add-notices.php\' <b>skip_custom_fields=\'1\'</b> ><br/>
                  &emsp;&lt;cms:set s_fieldname = \'notices_image\' />
                  &emsp;&lt;img src="&lt;cms:embed \'securefile_link.html\' />" /><br/>
                  &lt;/cms:pages&gt;
                  </pre>


so i made the following change in the code and took it out of the iteration loop, new code is:
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:set s_fieldname = 'notices_image' />
<cms:content_type 'application/json'/>

   {
   "notices" :
   [
      <cms:pages masterpage='add-notices.php' skip_custom_fields='0'>
      {
            "noticesImage" :  "<cms:set s_link = "<cms:embed 'securefile_link.html' />" /><cms:if s_link ><cms:show s_link /></cms:if>",            
            "noticesTitle" :  "<cms:show notices_title />",
            "noticesContent" :  "<cms:addslashes><cms:show notices_content /></cms:addslashes>",
            "noticesDate" :  "<cms:addslashes><cms:show notices_date /></cms:addslashes>"
      }<cms:if "<cms:not k_paginated_bottom/>">,</cms:if>
      </cms:pages>
   ]
}
<?php COUCH::invoke(); ?>
Image
where innovation meets technology
18 posts Page 2 of 2