小编ati*_*tif的帖子

如何在cms/content_home.phtml上调用newsletter/subscribe.phtml?

我想在内容区域的主页上创建一个新闻订阅框,为此我创建了一个CMS页面,我在新闻订阅文件中放置的其他代码也可以调用.

我想这样称呼它:

<?php echo $this->getLayout()->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe.phtml')->toHtml(); ?>
Run Code Online (Sandbox Code Playgroud)

但它没有显示出来.

为什么?

magento magento-1.4 magento-1.5

2
推荐指数
1
解决办法
1万
查看次数

如何使用curl发布数据并根据发布的数据获得响应

这是我的POST数据代码:

<?php
$data = array("account" => "1234", "dob" => "30051987", "site" => "mytestsite.com");
$data_string = json_encode($data);

$url = 'http://mydomain.com/curl.php';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_close($ch);
$json_result = json_decode($result, true);
?>

<p>Your confirmation number is: <strong><?php echo $json_result['ConfirmationCode']; ?></strong></p>
Run Code Online (Sandbox Code Playgroud)

而域/服务器curl.php文件代码如下:

<?php
// header 
header("content-type: application/json");

if($_POST):
    echo json_encode(array('ConfirmationCode' => 'somecode'));
else:
    echo json_encode(array('ConfirmationCode' => 'none'));
endif;
?> …
Run Code Online (Sandbox Code Playgroud)

php curl

2
推荐指数
2
解决办法
3万
查看次数

如何通过ajax发送JSON数组?

var storeSettings = [];

                        obj.find(o_widgetClass).each(function(){
                            var storeSettingsStr          = {};
                            storeSettingsStr['id']        = $(this).attr('id');
                            storeSettingsStr['style']     = $(this).attr('data-widget-attstyle');
                            storeSettingsStr['title']     = $(this).children('header').children('h2').text();
                            storeSettingsStr['hidden']    = ($(this).is(':hidden') ? 1 : 0);
                            storeSettingsStr['collapsed'] = ($(this).hasClass('powerwidget-collapsed') ? 1 : 0);
                            storeSettings.push(storeSettingsStr);
                        }); 

                        var storeSettingsObj = JSON.stringify( {'widget':storeSettings} );

                        /* Place it in the storage(only if needed) */
                        if(getKeySettings != storeSettingsObj){
                            //alert(storeSettingsObj);
                            var memberfilter = new Array();
                            memberfilter[0] = "id";
                            memberfilter[1] = "style";
                            var jsonText = JSON.stringify(storeSettings, memberfilter);
alert(jsonText);


   // it gives this result 
[{"id":"widget1"},{"id":"widget3","style":"black"},{"id":"widget4"},{"id":"widget5"},{"id":"widget2","style":"black"},{"id":"widget6"},{"id":"widget7"},{"id":"widget9"},{"id":"widget8"},{"id":"widget10"},{"id":"widget12"},{"id":"widget13"},{"id":"widget11"},{"id":"widget14"}]
Run Code Online (Sandbox Code Playgroud)

现在我如何通过 jquery ajax 发送它?我正在尝试使用下面提到的代码 …

php jquery json

1
推荐指数
1
解决办法
1万
查看次数

如何在具有特定属性值的iframe的clicked元素上应用css类?

获取iframe的内容后,将其过滤以获取具有自定义属性的第一个元素data-type = filled.但是我无法在该特定元素上应用类.

这是我的代码:

var clicked_content = event.target.outerHTML, // gives the content being clicked

content = $(clicked_content).find("*[data-type='filled']:first").andSelf().html(); // this gives me the required content

// this was supposed to add a class to particular element
content.parent.addClass("highlight");
Run Code Online (Sandbox Code Playgroud)

我也试过这样做:

$(event.target).children().find("*[data-type='filled']:first").andSelf().addClass('highlight');
Run Code Online (Sandbox Code Playgroud)

jquery

0
推荐指数
1
解决办法
148
查看次数

标签 统计

jquery ×2

php ×2

curl ×1

json ×1

magento ×1

magento-1.4 ×1

magento-1.5 ×1