Results 1 to 3 of 3

Thread: Isotope + Content elements + Changelanguage

  1. #1
    New user
    Join Date
    11-16-11.
    Location
    Berlin
    Posts
    18

    Default Isotope + Content elements + Changelanguage

    Hi,

    I'm trying to use content elements in Isotope Product (similar to what is described here).
    I managed to do it, now my Products have content elements, like in Article module.

    Now, how do I use changelanguage backend feature with that? I have two page trees in different languages with identical structure, they are properly connected by language, and Changelanguage module works correctly in Frontend, but doesn't appear in the Backend.

    I just need some hints, where to look further.
    Thanks.

  2. #2
    New user
    Join Date
    06-08-18.
    Posts
    1

    Default

    Hey vini,

    just found your post, that you already integrate content elements to isotope products. Is your work available as extension?
    Would like to do the same, but i'm struggling with the basics (tl_content is not allowed).

    Regards,
    Dennis

  3. #3
    New user
    Join Date
    11-16-11.
    Location
    Berlin
    Posts
    18

    Default

    Quote Originally Posted by denniserdmann View Post
    Is your work available as extension?
    Actually, it is... but it contains a lot of other custom improvements for my own projects... May be I should find time and publish some of it as an extension.

    If you familiar with "Extending Contao" concept, just use this:
    PHP Code:
    // config/config.php
    $GLOBALS['BE_MOD']['isotope']['iso_products']['tables'][] = 'tl_content';
    $GLOBALS['FE_MOD']['isotope']['iso_productreader'] = 'AppBundle\Module\ProductReaderCustom';

    // dca/tl_content.php
    if (\Input::get('do') == 'iso_products' && \Input::get('table') == 'tl_content') {
        
    $GLOBALS['TL_DCA']['tl_content']['config']['ptable'] = 'tl_iso_product';
    }

    // dca/tl_iso_product.php
    if (\Input::get('do') == 'iso_products' && !\Input::get('id')) {
        
    $GLOBALS['TL_DCA']['tl_iso_product']['config']['ctable'][] = 'tl_content';
        
    $GLOBALS['TL_DCA']['tl_iso_product']['list']['operations']['edit']['href'] = 'table=tl_content';
        
    array_insert($GLOBALS['TL_DCA']['tl_iso_product']['list']['operations'], 1, [
            
    'editheader' => [
                
    'label' => &$GLOBALS['TL_LANG']['tl_iso_product']['edit'],
                
    'href'  => 'act=edit',
                
    'icon'  => 'header.svg'
            
    ]
        ]);
    }

    // class ProductReaderCustom
    namespace AppBundle\Module;

    use 
    Haste\Http\Response\HtmlResponse;
    use 
    Haste\Input\Input;
    use 
    Isotope\Model\Product;

    class 
    ProductReaderCustom extends ProductReader
    {
        
    /**
         * Generate module
         * @return void
         */
        
    protected function compile()
        {
            global 
    $objPage;
            global 
    $objIsotopeListPage;

            
    $objProduct Product::findAvailableByIdOrAlias(Input::getAutoItem('product'));

            if (
    null === $objProduct) {
                
    $this->generate404();
            }

            
    $arrElements = array();
            
    $objCte = \ContentModel::findPublishedByPidAndTable($objProduct->getProductId(), 'tl_iso_product');

            if (
    $objCte !== null)
            {
                
    $intCount 0;
                
    $intLast $objCte->count() - 1;

                while (
    $objCte->next())
                {
                    
    $arrCss = array();

                    
    /** @var ContentModel $objRow */
                    
    $objRow $objCte->current();

                    
    // Add the "first" and "last" classes (see #2583)
                    
    if ($intCount == || $intCount == $intLast)
                    {
                        if (
    $intCount == 0)
                        {
                            
    $arrCss[] = 'first';
                        }

                        if (
    $intCount == $intLast)
                        {
                            
    $arrCss[] = 'last';
                        }
                    }

                    
    $objRow->classes $arrCss;
                    
    $arrElements[] = $this->getContentElement($objRow$this->strColumn);
                    ++
    $intCount;
                }
            }

            
    $arrConfig = array(
                
    'module'      => $this,
                
    'template'    => $this->iso_reader_layout ? : $objProduct->getType()->reader_template,
                
    'gallery'     => $this->iso_gallery ? : $objProduct->getType()->reader_gallery,
                
    'buttons'     => $this->iso_buttons,
                
    'useQuantity' => $this->iso_use_quantity,
                
    'jumpTo'      => $objIsotopeListPage ? : $objPage,
                
    'elements'    => $arrElements
            
    );

            if (\
    Environment::get('isAjaxRequest')
                && \
    Input::post('AJAX_MODULE') == $this->id
                
    && \Input::post('AJAX_PRODUCT') == $objProduct->getProductId()
            ) {
                try {
                    
    $objResponse = new HtmlResponse($objProduct->generate($arrConfig));
                    
    $objResponse->send();
                } catch (\
    InvalidArgumentException $e) {
                    return;
                }
            }

            
    $this->addMetaTags($objProduct);
            
    $this->addCanonicalProductUrls($objProduct);

            
    $this->Template->product       $objProduct->generate($arrConfig);
            
    $this->Template->product_id    $this->getCssId($objProduct);
            
    $this->Template->product_class $this->getCssClass($objProduct);
            
    $this->Template->referer       'javascript:history.go(-1)';
            
    $this->Template->back          $GLOBALS['TL_LANG']['MSC']['goBack'];
        }

        
    /**
         * Generates a 404 page and stops page output.
         */
        
    private function generate404()
        {
            global 
    $objPage;
            
    /** @var \PageError404 $objHandler */
            
    $objHandler = new $GLOBALS['TL_PTY']['error_404']();
            
    $objHandler->generate($objPage->id);
            exit;
        }

    Then, add this in your product reader template (which is iso_reader_default.html5 by default):
    PHP Code:
    <?php if (!empty($this->config['elements'])) echo implode($this->config['elements']); ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •