Closed jasonkarlin12 closed 7 months ago
@jasonkarlin12 could you provide me with the form xml file?
` <?xml version="1.0" encoding="UTF-8"?>
`@jasonkarlin12 this code works good for me
public function getAccordianData()
{
$accordian = Array();
$accordianData = Array();
$componentData = $this->getData('component_data')['dynamic_rows']['dynamic_rows'];
foreach ($componentData as $row) {
$accordianData['title'] = $row['title'];
$accordianData['content'] = $row['wysiwyg'];
$accordian[] = $accordianData;
}
return $accordian;
}
Sorry, wasn't clear. That code is working to get the data but the content is still encoded. I'm trying to figure out how to decode the content. What I get on the page looks like this
`
<div class="marketing-content-accordian-content">PHN0eWxlPiNodG1sLWJvZHkgW2RhdGEtcGItc3R5bGU9SVhXS1dER117anVzdGlmeS1jb250ZW50OmZsZXgtc3RhcnQ7ZGlzcGxheTpmbGV4O2ZsZXgtZGlyZWN0aW9uOmNvbHVtbjtiYWNrZ3JvdW5kLXBvc2l0aW9uOmxlZnQgdG9wO2JhY2tncm91bmQtc2l6ZTpjb3ZlcjtiYWNrZ3JvdW5kLXJlcGVhdDpuby1yZXBlYXQ7YmFja2dyb3VuZC1hdHRhY2htZW50OnNjcm9sbH08L3N0eWxlPjxkaXYgZGF0YS1jb250ZW50LXR5cGU9InJvdyIgZGF0YS1hcHBlYXJhbmNlPSJjb250YWluZWQiIGRhdGEtZWxlbWVudD0ibWFpbiI+PGRpdiBkYXRhLWVuYWJsZS1wYXJhbGxheD0iMCIgZGF0YS1wYXJhbGxheC1zcGVlZD0iMC41IiBkYXRhLWJhY2tncm91bmQtaW1hZ2VzPSJ7fSIgZGF0YS1iYWNrZ3JvdW5kLXR5cGU9ImltYWdlIiBkYXRhLXZpZGVvLWxvb3A9InRydWUiIGRhdGEtdmlkZW8tcGxheS1vbmx5LXZpc2libGU9InRydWUiIGRhdGEtdmlkZW8tbGF6eS1sb2FkPSJ0cnVlIiBkYXRhLXZpZGVvLWZhbGxiYWNrLXNyYz0iIiBkYXRhLWVsZW1lbnQ9ImlubmVyIiBkYXRhLXBiLXN0eWxlPSJJWFdLV0RHIj48ZGl2IGRhdGEtY29udGVudC10eXBlPSJ0ZXh0IiBkYXRhLWFwcGVhcmFuY2U9ImRlZmF1bHQiIGRhdGEtZWxlbWVudD0ibWFpbiI+PHA+Q29udGVudDE8L3A+PC9kaXY+PC9kaXY+PC9kaXY+</div>
<div class="marketing-content-accordian-title">title2</div>
<div class="marketing-content-accordian-content">PHN0eWxlPiNodG1sLWJvZHkgW2RhdGEtcGItc3R5bGU9WEJMNDFFMF17anVzdGlmeS1jb250ZW50OmZsZXgtc3RhcnQ7ZGlzcGxheTpmbGV4O2ZsZXgtZGlyZWN0aW9uOmNvbHVtbjtiYWNrZ3JvdW5kLXBvc2l0aW9uOmxlZnQgdG9wO2JhY2tncm91bmQtc2l6ZTpjb3ZlcjtiYWNrZ3JvdW5kLXJlcGVhdDpuby1yZXBlYXQ7YmFja2dyb3VuZC1hdHRhY2htZW50OnNjcm9sbH08L3N0eWxlPjxkaXYgZGF0YS1jb250ZW50LXR5cGU9InJvdyIgZGF0YS1hcHBlYXJhbmNlPSJjb250YWluZWQiIGRhdGEtZWxlbWVudD0ibWFpbiI+PGRpdiBkYXRhLWVuYWJsZS1wYXJhbGxheD0iMCIgZGF0YS1wYXJhbGxheC1zcGVlZD0iMC41IiBkYXRhLWJhY2tncm91bmQtaW1hZ2VzPSJ7fSIgZGF0YS1iYWNrZ3JvdW5kLXR5cGU9ImltYWdlIiBkYXRhLXZpZGVvLWxvb3A9InRydWUiIGRhdGEtdmlkZW8tcGxheS1vbmx5LXZpc2libGU9InRydWUiIGRhdGEtdmlkZW8tbGF6eS1sb2FkPSJ0cnVlIiBkYXRhLXZpZGVvLWZhbGxiYWNrLXNyYz0iIiBkYXRhLWVsZW1lbnQ9ImlubmVyIiBkYXRhLXBiLXN0eWxlPSJYQkw0MUUwIj48ZGl2IGRhdGEtY29udGVudC10eXBlPSJ0ZXh0IiBkYXRhLWFwcGVhcmFuY2U9ImRlZmF1bHQiIGRhdGEtZWxlbWVudD0ibWFpbiI+PHA+Q29udGVudDI8L3A+PC9kaXY+PC9kaXY+PC9kaXY+</div>
`
@jasonkarlin12 try to use \Grasch\AdminUi\Model\Base64::decode method
this works for me
before decoding PHA+YXNrbG1kYWxza2RtbGFrc2Q8L3A+
after decoding <p>asklmdalskdmlaksd</p>
public function getAccordianData()
{
$accordian = Array();
$accordianData = Array();
$componentData = $this->getData('component_data')['dynamic_rows']['dynamic_rows'];
foreach ($componentData as $row) {
$accordianData['title'] = $row['title'];
$accordianData['content'] = $this->base64->decode($row['wysiwyg']);
$accordian[] = $accordianData;
}
return $accordian;
When I try that, I get this error on the page. Is there something else I need to add to the widget class?
Error filtering template: Warning: Undefined property: TrumpOrg\Core\Block\Content\Widget\MarketingContentAccordian::$base64 in /home/developer/Sites/trump/app/code/TrumpOrg/Core/Block/Content/Widget/MarketingContentAccordian.php on line 17
@jasonkarlin12 have you added the base64 property to the constructor of the MarketingContentAccordian class?
That worked now. Sorry, I'm still pretty new to PHP/Magento so I appreaciate you walking me through all that. I added the __construct and added a local Base64 and am now able to see the decoded value on the screen. Thanks so much!!
I'm trying to create an accordian widget to allow users to enter multiple rows with a title and rich html content. I updated the dynamicRows example to use a wysiwyg field for field_2 and I can save the data but I'm not sure how to decode that data to display. In my widget class, I'm looping through and grabbing the data. Should I be using the getData method from AbstractWidget (which includes the call to decodeComponentValue? I'm not clear what the key/index values should be.
`<?php namespace TrumpOrg\Core\Block\Content\Widget;
use Magento\Widget\Block\BlockInterface;
class MarketingContentAccordian extends \Grasch\AdminUi\Block\Widget\AbstractWidget implements BlockInterface { protected $_template = "content/widget/marketing-content-accordian.phtml";
} `