Adding fields to the ZOO category
This article is about the ZOO component for Joomla CMS. First of all consider adding a simple text field to the right side of the admin panel category ZOO.
1. Open media/zoo/applications/blog/aplication.xml and after the line
<param name="image" type="zooimage" label="Image" description="Choose a category image." />
add:
<param name="ourname" type="text" label="Our field name" description="Our tip" />
2. Output in category template media/zoo/applications/blog/templates/default/category.php
<?php echo $this->category->getParams()->get('content.ourname'); ?>
ourname is our unique name. You can add a picture field ZOO instead of a text field. Сhange type="text" to type="zooimage". We get src of the picture in the output.
Adding fields to the main area of the ZOO category admin panel
<div class="element element-description">
<strong title="Hint">New field with editor</strong>
<div>
<?php
echo $this->app->system->editor->display('description1', $this->category->description1, null, null, '60', '20', array('pagebreak', 'readmore', 'article')) ;
?>
</div>
</div>
We named the field description1. It appeared, but it does not save information.
3. Open the file administrator/components/com_zoo/controllers/category.php. Find the line
$post['description'] = $this->app->request->getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
and after it add$post['description1'] = $this->app->request->getVar('description1', '', 'post', 'string', JREQUEST_ALLOWRAW);
Now everything is saved correctly in admin panel. It remains only to display the data in the template.
4. Open media/zoo/applications/blog/templates/default/category.php Insert the output in the right place:
<?php echo $this->category->getText($this->category->description1); ?>
1. Open the file administrator/components/com_zoo/views/category/tmpl/edit.php This code is inserted in the right place:
<div class="element element-name">
<strong>Caption</strong>
<div id="name-edit">
<div class="row">
<input class="inputbox" type="text" name="mycaption" size="60" value="<?php echo $this->category->mycaption; ?>" />
</div>
</div>
</div>
2. Add in DB. Open the table zoo_category. Click the tab Structure. Add a line with our name. Choose type VARCHAR
3. Output in category template
<?php echo $this->category->mycaption; ?>
Comments
Post a Comment