0

I need cms page content which has a short code in it, so it returns shortcode. It should return HTML instead of that. I need to solve this via soap API v1.Below is the output I got.

page title

{{block type="imagegallery/imagegallery" name="imagegallery" category_id="13" template="imagegallery/main_category_01.phtml" }} {{block type="imagegallery/imagegallery" name="imagegallery" category_id="15" template="imagegallery/main_category_01.phtml" }}
<?php

require_once('../app/Mage.php');
Mage::app();

$client     = new SoapClient('http://localhost/project/api/soap/?wsdl');


$user_name  = $_POST["user_name"];
$password   = $_POST["password"];
$session    = $client->login($user_name, $password);

$response = array();
$pageId   = "41";
$page_sub_contain   = Mage::getModel('cms/page')->load($pageId);
$page_main_contain  = $page_sub_contain->getContent();

$result   = $page_main_contain;
$response = array(
    "status" => "1",
    "message" => "suceess",
    "contain" => $result
);

ob_start();
header('Content-type: application/json');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');

echo json_encode($response);
exit;

?>

1 Answer 1

1

Try following code:

$pageSubContain   = Mage::getModel('cms/page')->load($pageId);
$pageMainContain  = $pageSubContain->getContent();

/* @var $helper Mage_Cms_Helper_Data */
$helper = Mage::helper('cms');
$processor = $helper->getPageTemplateProcessor();
$html = $processor->filter($pageMainContain);
$response = array(
    "status" => "1",
    "message" => "suceess",
    "contain" => $html
);

[Update]

I tested using the following code. Working fine with the fresh installation.

$client     = new SoapClient('http://magento1941.com:8888/api/soap/?wsdl');


$user_name  = 'admin';
$password   = 'admin123';
$session    = $client->login($user_name, $password);

$response = array();
$pageId   = "11";
$pageSubContain   = Mage::getModel('cms/page')->load($pageId);
$pageMainContain  = $pageSubContain->getContent();

/* @var $helper Mage_Cms_Helper_Data */
$helper = Mage::helper('cms');
$processor = $helper->getPageTemplateProcessor();
$html = $processor->filter($pageMainContain);
$response = array(
    "status" => "1",
    "message" => "suceess",
    "contain" => $html
);

ob_start();
header('Content-type: application/json');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');

echo json_encode($response);
exit;

?>
5
  • It is giving me error "Fatal error: Call to a member function getPage() on a non-object". Commented Jul 5, 2019 at 8:11
  • Where you found getPage()?
    – Sohel Rana
    Commented Jul 5, 2019 at 8:14
  • in this preceding block which called by this page {{block type="imagegallery/imagegallery" name="imagegallery" category_id="13" template="imagegallery/main_category_01.phtml" }} Commented Jul 5, 2019 at 8:15
  • Show your clock code 'imagegallery/imagegallery'. Update your question with code.
    – Sohel Rana
    Commented Jul 5, 2019 at 8:17
  • You are absolutely right sir.....the second cms which is called from short code has a line as below...... which I commented ...working fine,...thank you "<?php //$pageid = Mage::getBlockSingleton('cms/page')->getPage()->getId(); ?>" Commented Jul 5, 2019 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.