Tutorial - How to add new page field in Quick.Cms v4.0

treewood (OpenSolution)

Avatar: treewood

2012-02-07 22:43

Here is tutorial "how to add new field to page data". This tutorial is designed to Quick.Cms v4.0.

In the example below we're adding the field named "date" but it could be any other desired field.

1. Edit templates/admin/pages.tpl and add code

<tr>
  <
td>$lang['sField1']</td>
  <
td><input type="text" name="sField1" value="$aData[sField1]" size="40" class="input" /></td>
</
tr>

before

<!-- tab options -->



2. Edit database/translations/en.php (or other language you have) and add:

$lang['sField1'] = "Date";

after:

// plugins


You can change "Date" to anything else.

3. Edit database/_fields.php and change add this:

'sField1'

after this code:

'sMetaDescription''sDescriptionFull'


Finally this shoud look like (in Quick.Cms v4.0 freeware version):
$aPagesFields = Array( 'iPage', 'iPageParent', 'sName', 'sNameTitle', 'sNameUrl', 'iStatus', 'iPosition', 'iType', 'iSubpagesShow', 'sDescriptionShort', 'sTemplate', 'sTheme', 'sUrl', 'sBanner', 'sMetaKeywords', 'sMetaDescription', 'sDescriptionFull', 'sField1' );

4. Edit templates/default/pages_default.tpl and add this:

option 1

<!-- IF:START FIELD---><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD--->

or this (if you want always display this extra field even it is empty):

option 2

<div class="field1">$lang['sField1']: $aData[sField1]</div>


before (you can choose other place in CONTAINER block) for example:

$aImages[1]


5. If you choosed first option from 4 step then edit actions/pages.php and add this:

if( !empty( $aData['sField1'] ) )
  
$oTpl->setIf'FIELD-1' );

after:

$oTpl->setIf'NAVIPATH' );


Note: In this step you added statement. This statement will display extra field if it is NOT EMPTY.

6. Log to admin panel and add some text to this field for example: 2012-02-07

7. Now you need to edit templates/default/style.css and add some styles to .field1 for example .field1{font-weight:bold;margin:10px 0;}

Thats all :)

If you want to display this extra field in sub-pages list then do 2 more steps:

8. Edit templates/default/pages_default.tpl and add this:

<!-- IF:START FIELD---><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD--->

or this (if you want always display this extra field even it is empty):

<div class="field1">$lang['sField1']: $aData[sField1]</div>

after (you can choose other place in SUBPAGES_DEFAULT block) for example:

<div class="description">$aData[sDescriptionShort]</div><!-- IF:END DESCRIPTION -->


9. If you choosed first option from 8 step then edit core/pages.php and add this:

if( !empty( $aData['sField1'] ) ){
  
$oTpl->setVariables'aData'$aData );
  
$oTpl->setIf'FIELD-1' );
}

before:

if( isset( $oFile ) && isset( $oFile->aImagesDefault[1][$aData['iPage']] ) ){


Have fun!

treewood (OpenSolution)

Avatar: treewood

2012-12-24 08:50

Tutorial "how to add new page field" to Quick.Cms v5.0 is moved to plugin:
http://opensolution.org/download,en,18.html?sDir=Quick.Cms/plugins#pagesNewField

Back to top
about us | contact