[TYPO3-english] Templates are lost when user copies page

Victor Livakovsky v-tyok at mail.ru
Sun Dec 4 16:56:37 CET 2011


> > Am 30.11.2011 04:04, schrieb André Hänsel:
> > > So, any solutions for having regular users be able to copy pages with
> > > extension templates?
> >
> > IMO you should change your TS and move things which change the output to
> > fields of the page properties. copying TS templates sounds a bit risky 
> > for
> > me because as integrator I would never know after some days where which 
> > TS
> > is and what is the final output.
>
> You mean, I will create one big template and then use conditions to check
> for a field of the page record? Good idea.
> Can I access the Page TSconfig from within a condition in the template?

Why do you need to access Page TS config from TS template?
Just extend page's TCA, add columns to page table in MySQL, and that's it. 
Here is an example of how I made simple banner management for a website:
Created an extension, which contained:
ext_tables.sql:
CREATE TABLE pages (
    tx_lvextpage_leaderbord_code int(11) DEFAULT '0' NOT NULL,
    tx_lvextpage_leaderbord_code_disable tinyint(3) DEFAULT '0' NOT NULL,
);

ext_tables.php:
$tempColumns = array (
    'tx_lvextpage_leaderbord_code' => array (
        'exclude' => 0,
        'label' => 
'LLL:EXT:lv_extpage/locallang_db.xml:pages.tx_lvextpage_leaderbord_code',
        'config' => array (
            'type' => 'input',
            'size' => '30',
            'eval' => 'int,nospace',
        )
    ),
    'tx_lvextpage_leaderbord_code_disable' => array (
        'exclude' => 0,
        'label' => 
'LLL:EXT:lv_extpage/locallang_db.xml:pages.tx_lvextpage_leaderbord_code_disable',
        'config' => array (
            'type' => 'check',
        )
    ),
);
t3lib_div::loadTCA('pages');
t3lib_extMgm::addTCAcolumns('pages',$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes('pages','tx_lvextpage_leaderbord_code;;;;1-1-1, 
tx_lvextpage_leaderbord_code_disable');

And that's it - it adds an input field for banner code and a checkbox for 
disabling banner to the page properties.

You can manipulate these values as you wish in TS. F.e., I made it like 
this:
lib.banners = COA
lib.banners.5 = TEXT
lib.banners.5.value (
<script type='text/javascript'><!--// <![CDATA[

)
lib.banners.10 = TEXT
lib.banners.10 {
  wrap =  OA_show(|);
  data = levelfield:-1,tx_lvextpage_leaderbord_code,slide
  if.isTrue.field = tx_lvextpage_leaderbord_code_disable
  if.negate = 1
}
lib.banners.15 = TEXT
lib.banners.15.value (

// ]]> --></script>
)

So, in the end a user may input the banner;s code on top-level page and it 
will be inherited by children, but may be disabled for any page via 
checkbox.
Your goals may be different, but, I think, you got the idea. 



More information about the TYPO3-english mailing list