Jump to content

How to paste variable into function in controller


Przemysław Suszek

Recommended Posts

I hope I type right topic. What I need to know ? From controller I have list of cms page from my shop. Then I want to get content but I don’t know how.

 

My controller:

class ProductController extends ProductControllerCore {

    public function initContent() {
        parent::initContent();
        $cmsList = CMS::listCms();
        $this->context->smarty->assign('cmsList', $cmsList);
    }
    
    public function getCMSContent($cmsID){
        $cms = new CMS($cmsID, intval($cookie->id_lang));
        return $cms;
    }
}

In my product.tpl file I have:

{$productCategory = $product->category}
                {foreach from=$cmsList item=varCMS}
                    {$cmsID = $varCMS.id_cms}
                    {$cmdTitle = $varCMS.meta_title}
                    {if $cmdTitle == $productCategory}
                        <section class="page-product-box">
                <h3 class="page-product-heading">Title</h3>
                <div class="rte"><p>{ProductController::getCMSContent($cmsID)->content[1]}</p></div>
            </section>
                    {/if}
                {/foreach}

How to paste my cms ID to getCMSContent ?

 

Kind regards

 

 

---edit

Compare product category with cms title. If the same then display cms content.

Edited by mr.suchy (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...