Page: | 1 |
Topic:

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

treewood
OpenSolution
See profile of: treewood
2012-02-07 22:43:30
Votes: 0
Vote answer in plus Vote answer in minus
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-1 --><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD-1 -->
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-1 --><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD-1 -->
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!
trzykas
See profile of: trzykas
2012-02-07 23:52:08
Votes: 0
Vote answer in plus Vote answer in minus
przydał by się jakiś tutel opisujący możliwość dodania pola na frontendzie zapisującego się do bazy z odczytem w PA - mogło by powstać wiele darmowych pluginów wpływających pozytywnie na rozwój QCMS i jego popularyzację np. formularze rezerwacji, komentarze, głosowania etc

-------------------------------------------------------
feminizm kończy się wraz z zakupem lodówki
boboo
See profile of: boboo
2012-02-08 06:28:35
Votes: 0
Vote answer in plus Vote answer in minus
Już pracuję nad pluginami :-)
Bo zapis z "frontendu" funkcjonuje bez problemu.
Chocby tu:
http://opensolution.org/Quick.Cms/forum/pagesvotes-w-wersji-4,2022.html
przy zapisywaniu Votes.

-------------------------------------------------------
http://qc-plugins.kimla.de
treewood
OpenSolution
See profile of: treewood
2012-02-08 07:10:57
Votes: 0
Vote answer in plus Vote answer in minus
trzykas - to juz wieksza zabawa bo trzeba zrobic formularz, zabezpieczyc go jakos przed intruzami i zapisac dane. Ale moze powstanie jakis dodatek spelniajacy ta funkcjonalnosc i bedacy przykladem do rozszerzen.

boboo - trzykas napisal "darmowych pluginów" a nie platnych pluginow.
boboo
See profile of: boboo
2012-02-08 07:19:38
Votes: 0
Vote answer in plus Vote answer in minus
treewood,
a gdzie napisałem "płatne pluginy"?

-------------------------------------------------------
http://qc-plugins.kimla.de
Page: | 1 |
 


If You want to do this operation, please log in first ».
If You don't have an account please register ».
Valid XHTML 1.0! Valid CSS! version: 2.2.0-alfa | powered by Quick.Forum