문제

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;

?>
도움이 되었습니까?

해결책

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;

?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top