Перейти к содержимому


Фотография
- - - - -

Создание своего элемента


  • Закрытая тема Тема закрыта
Сообщений в теме: 48

#1 Katerina

Katerina

Отправлено 20 February 2013 - 13:57

Как вывести созданный элемент в админку?

Поясняю
Как сделать так, что бы элемент появился вот в этом месте?

Изображение

В соответствии с инструкцией была создана папка jbcominfo
в ней php и  xml (в настоящий момент внутри копия существующего элемента, который я после буду модифицировать)

Изображение

Проблема - свой элемент не появляется в админ зоне, почему?

  • 0

#2 Katerina

Katerina

Отправлено 20 February 2013 - 15:30

RomanL - где же Вы??!!!


я решила пойти по другому пути и создать элемент не внутри  JBZoo а в элементах Zoo
оно отобразилось в Форма - если просто скопировать элемент текст поменяв text на cominfo

однако мне не нужно еще одно поле текста, следуя вот этой инструкции

http://www.yootheme....-custom-element

я создала нужный мне аналог прописав в xml

   <params>
   </params>
   <params group="render">
   </params>
а в php файл следующее

<?php
/**
* @package   com_zoo
* @author    YOOtheme [url]http://www.yootheme.com[/url]
* @copyright Copyright (C) YOOtheme GmbH
* @license   [url]http://www.gnu.org/licenses/gpl.html[/url] GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');


class ElementCominfo extends Element {
   public function edit() {
   }
}


public function edit() {
   $html = array();
   $html[] = $this->app->html->_('control.editrow', JText::_('zCountry'),    $this->app->html->_('control.text', $this->getControlName('zcountry'), $this->get('zcountry'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zCity'), $this->app->html->_('control.text', $this->getControlName('zcity'), $this->get('zcity'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zOfficeAddress'), $this->app->html->_('control.text', $this->getControlName('zofficeaddress'), $this->get('zofficeaddress'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zWarehouseAddress'), $this->app->html->_('control.text', $this->getControlName('zwarehouseaddress'), $this->get('zwarehouseaddress'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zPhone'), $this->app->html->_('control.text', $this->getControlName('zphone'), $this->get('zphone'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zEmail'), $this->app->html->_('control.text', $this->getControlName('zemail'), $this->get('zemail'), 'size="60" maxlength="255"'));

   return implode("\n", $html);
}


public function render($params = array()) {
   return $this->get('zcountry') . ', ' . $this->get('zcity') . ', ' .$this->get('zofficeaddress') . ', ' .$this->get('zwarehouseaddress') . ', ' .$this->get('zphone') . ', ' .$this->get('zemail');
}

public function hasValue($params = array()) {
   $street = $this->get('zcountry');
   $zip = $this->get('zcity');
   $country = $this->get('zofficeaddress');
   $country = $this->get('zwarehouseaddress');
   $country = $this->get('zphone');
   $country = $this->get('zemail');
   return !empty($zcountry) ||!empty($zcity) ||($zofficeaddress) ||($zwarehouseaddress) ||($zphone) ||($zemail);
}
сохранила

вот эта страница Риэлтор [ Редактировать поля ]
перестала открываться, там просто чистая (белая) страницаё
(в принципе закладка редактировать поля в любом шаблоне не открывается)

где именно у меня ошибка, почему так происходит?
  • 0

#3 Katerina

Katerina

Отправлено 20 February 2013 - 19:44

Так, мне снова 3 года ждать ответа??!!
  • 0

#4 RomanL

RomanL

Отправлено 20 February 2013 - 20:22

Папка с элементом должна быть здесь: media\zoo\applications\jbuniversal\elements\

Покажите полностью XML файл

если файлы с элементом называются jbcominfo, значит везде должно быть jbcominfo

Здесь: class ElementCominfo extends Element {  должно быть:

class ElementJBCominfo extends Element {
  • 0
[color=#aa0000]Не забывайте нажимать кнопку «Вопрос Решён» и «+1» под сообщением, которое Вам помогло[/color]

#5 Katerina

Katerina

Отправлено 20 February 2013 - 21:05

<?xml version="1.0" encoding="utf-8"?>
<element type="jbcominfo" group="JBZoo">
   <name>Address</name>
   <author>John Doe</author>
   <creationDate>April 2010</creationDate>
   <copyright>THIS CAN PROBABLY BE OMITTED</copyright>
   <authorEmail>john @ doe.com</authorEmail>
   <authorUrl>[url]http://www.johndoe.com[/url]</authorUrl>
   <version>1.0.0</version>
   <description>HTML address fields</description>


   <params>
            <param name="default" type="text" default="" label="Default" description="" />
   </params>

   <params group="render">
            <param name="zcountry" type="text" default="" label="Country" description="" />
            <param name="zcity" type="text" default="" label="City" description="" />
            <param name="zofficeaddress" type="text" default="" label="Office Address" description="" />
            <param name="zwarehouseaddress" type="text" default="" label="Warehouse Address" description="" />
            <param name="zphone" type="text" default="" label="Phone" description="" />
            <param name="zemail" type="text" default="" label="Email" description="" />
   </params>


</element>

  • 0

#6 Katerina

Katerina

Отправлено 20 February 2013 - 21:15

папка находится здесь

/media/zoo/applications/jbuniversal/elements/jbcominfo


если все тоже самое поместить по адресу

media/zoo/elements


в библиотеке элементов оно отобразится
  • 0

#7 RomanL

RomanL

Отправлено 20 February 2013 - 21:37

Если все правильно, должно работать из этой папки /media/zoo/applications/jbuniversal/elements/jbcominfo
  • 0
[color=#aa0000]Не забывайте нажимать кнопку «Вопрос Решён» и «+1» под сообщением, которое Вам помогло[/color]

#8 RomanL

RomanL

Отправлено 20 February 2013 - 21:39

вот это исправили? class ElementJBCominfo extends Element
  • 0
[color=#aa0000]Не забывайте нажимать кнопку «Вопрос Решён» и «+1» под сообщением, которое Вам помогло[/color]

#9 Katerina

Katerina

Отправлено 20 February 2013 - 21:49

да - этот пхп код вешает всю админку

<?php
/**
* @package   com_zoo
* @author    YOOtheme [url]http://www.yootheme.com[/url]
* @copyright Copyright (C) YOOtheme GmbH
* @license   [url]http://www.gnu.org/licenses/gpl.html[/url] GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');


class ElementJBCominfo extends Element {
   public function edit() {
   }
}


public function edit() {
   $html = array();
   $html[] = $this->app->html->_('control.editrow', JText::_('zCountry'),    $this->app->html->_('control.text', $this->getControlName('zcountry'), $this->get('zcountry'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zCity'), $this->app->html->_('control.text', $this->getControlName('zcity'), $this->get('zcity'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zOfficeAddress'), $this->app->html->_('control.text', $this->getControlName('zofficeaddress'), $this->get('zofficeaddress'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zWarehouseAddress'), $this->app->html->_('control.text', $this->getControlName('zwarehouseaddress'), $this->get('zwarehouseaddress'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zPhone'), $this->app->html->_('control.text', $this->getControlName('zphone'), $this->get('zphone'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zEmail'), $this->app->html->_('control.text', $this->getControlName('zemail'), $this->get('zemail'), 'size="60" maxlength="255"'));

   return implode("\n", $html);
}


public function render($params = array()) {
   return $this->get('zcountry') . ', ' . $this->get('zcity') . ', ' .$this->get('zofficeaddress') . ', ' .$this->get('zwarehouseaddress') . ', ' .$this->get('zphone') . ', ' .$this->get('zemail');
}

public function hasValue($params = array()) {
   $street = $this->get('zcountry');
   $zip = $this->get('zcity');
   $country = $this->get('zofficeaddress');
   $country = $this->get('zwarehouseaddress');
   $country = $this->get('zphone');
   $country = $this->get('zemail');
   return !empty($zcountry) ||!empty($zcity) ||($zofficeaddress) ||($zwarehouseaddress) ||($zphone) ||($zemail);
}
в таком варианте выдается совершенно чистый лист на редактировании полей
  • 0

#10 Katerina

Katerina

Отправлено 20 February 2013 - 21:56

Появился если код модифицировать следующим способом

<?php
/**
* @package   com_zoo
* @author    YOOtheme [url]http://www.yootheme.com[/url]
* @copyright Copyright (C) YOOtheme GmbH
* @license   [url]http://www.gnu.org/licenses/gpl.html[/url] GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');


class ElementJBCominfo extends ElementRepeatable implements iRepeatSubmittable {


   protected function _hasValue($params = array()) {
      $value = $this->get('value', $this->config->get('default'));
      return !empty($value) || $value === '0';
   }


   protected function _getSearchData() {
      return $this->get('value', $this->config->get('default'));
   }

   protected function _edit() {
   $html = array();
   $html[] = $this->app->html->_('control.editrow', JText::_('zcountry'),    
                  $this->app->html->_('control.text', $this->getControlName('zcountry'), 
                  $this->get('zcountry'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zcity'),    
                  $this->app->html->_('control.text', $this->getControlName('zcity'), 
                  $this->get('zcity'), 'size="60" maxlength="255"'));
   $html[] = $this->app->html->_('control.editrow', JText::_('zphone'),    
                  $this->app->html->_('control.text', $this->getControlName('zphone'), 
                  $this->get('zphone'), 'size="60" maxlength="255"'));

   $html[] = $this->app->html->_('control.editrow', JText::_('zemail'),    
                  $this->app->html->_('control.text', $this->getControlName('zemail'), 
                  $this->get('zemail'), 'size="60" maxlength="255"'));

   return implode("\n", $html);
   }



   protected function _render($_params=array()){
         return $this->get('zcountry') . ', ' . $this->get('zcity') . ','.  $this->get('zphone') . ','. $this->get('zemail') ;
   }



   public function _renderSubmission($params = array()) {
           return $this->_edit();
   }

        public function hasValue($params = array()) {
          $street = $this->get('zcountry');
          $zip = $this->get('zcity');
               $zip = $this->get('zphone');
               $zip = $this->get('zemail');
          return !empty($zcountry) ||!empty($zcity) ||!empty($zphone) ||!empty($zemail);
}

}

  • 0




Click to return to top of page in style!