-2

I am trying to securely echo out content that exists within my opencart database.

The table is called oc_category_description and the row content I want to echo is within a row called seo_h2

My goal is to echo the content within between opening / closing H2 tags on my TPL file.

This works for the row "name"

<?php echo $category['name']; ?>

But this it doesn't work

<?php echo $category['seo_h2']; ?>`

How do I safely do this? I am using mysqli, OpenCart 2.3

goto
  • 7,908
  • 10
  • 48
  • 58

4 Answers4

1
<?php print_r($category); ?>`

it will give you the result of complete row.

further you can work with loop for fetching the whole row like below:

foreach($category as $cat){
  echo $cat;
  }

keep coding :)

syed
  • 289
  • 1
  • 5
  • 17
0

Try:

$a = '<h2>demo example</h2>';
echo preg_replace("/<.*?>/", " ", $a);
Divyam Solanki
  • 461
  • 2
  • 7
  • 25
0

If you want to get multidimensional Array data then you should get multidimensional array for $categories

$categories = /*your multidimensional array*/
foreach ($categories as $category){
   echo $category["name"];
   echo $category["seo_h2"];
}

I thinks this works for you

HaiderAli
  • 21
  • 7
0

That's more complex than your description. OpenCart uses MVC Model: catalog/model/catalog/category.php (function getCategory) passing the information to Controller: catalog/controller/product/category.php

Which you need to add the following to this file: catalog/controller/product/category.php

Find this line:

$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');

and add this after:

$data['seo_h2'] = $category_info['seo_h2'];

Now in the view file (category.tpl) you can write this:

<?php echo $category['seo_h2']; ?>
Konstantinos
  • 418
  • 3
  • 10