Итак, задача!
При добавлении материала необходимо чтобы были поля, расположенные в ряд (3 столбика). первое поле - добавить слово. НО!!! самое важное!!! это слово подгружается АЯКСОМ и нажав на нужное слово - оно остаётся в этом поле! И ОНО ДОЛЖНО БЫТЬ КЛИКАБЕЛЬНЫМ! (как на некоторых сайтах при добавлении города, например), затем второе поле - просто текст, третье - как первое, только без кликабельности!!!
и таких строк с такими полями необходимо добавлять нажатием обычного плюсика!
Уважаемые знатоки, возможно ли такое сделать в Jbzoo? Может этот JBSelectCascade можно даже так настроить? И как это реализовать? Заранее спасибо!
#1
Отправлено 26 May 2013 - 08:33
#2
Отправлено 27 May 2013 - 18:40
Сделать то можно, но придется все писать ручками. Готовых настроек нет.
В этом разделе вам помогут по вашему существующему коду, а за "написать с нуля" вам скорее всего в этот раздел
Отключайте проверку лицензий как можно скорее!
— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.
#3
Отправлено 12 June 2013 - 16:03
Задача упрощается!
При добавлении материала необходимо чтобы были поля, расположенные в ряд (2 столбика). оба поля для добавления текста - text.
и таких строк с такими полями необходимо добавлять нажатием обычного плюсика!
Заранее спасибо!
#4
Отправлено 12 June 2013 - 16:24
если за основу взять элемент text, в ПХП файле надо добавить ещё одно поле. Но я честно говоря не понял где!!!
#6
Отправлено 12 June 2013 - 19:53
Посмотрите этот файл \media\zoo\elements\text\text.php
Нужно изменить метод _edit()
он рендерит текстовое поле.
Отключайте проверку лицензий как можно скорее!
— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.
#7
Отправлено 13 June 2013 - 19:33
<?php
/**
* @package com_zoo
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl.html 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: ElementIngr
The text element class
*/
class ElementIngr extends ElementRepeatable implements iRepeatSubmittable {
/*
Function: _hasValue
Checks if the repeatables element's value is set.
Parameters:
$params - render parameter
Returns:
Boolean - true, on success
*/
protected function _hasValue($params = array()) {
$value = $this->get('value', $this->config->get('default'));
return !empty($value) || $value === '0';
}
/*
Function: _getSearchData
Get repeatable elements search data.
Returns:
String - Search data
*/
protected function _getSearchData() {
return $this->get('value', $this->config->get('default'));
}
/*
Function: _edit
Renders the repeatable edit form field.
Returns:
String - html
*/
protected function _edit() {
$html = array();
$html[] = '<div>Ingredients</div>';
$html[] = $this->app->html->_('control.text', $this->getControlName('ingredients'), $this->get('ingredients', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>Amount</div>';
$html[] = $this->app->html->_('control.text', $this->getControlName('amount'), $this->get('amount', $this->config->get('default')), 'size="50" maxlength="150"');
}
/*
Function: _renderSubmission
Renders the element in submission.
Parameters:
$params - AppData submission parameters
Returns:
String - html
*/
public function _renderSubmission($params = array()) {
return $this->_edit();
}
public function _render($params = array()) {
return '<div class="' .JText::_('ingredients'). '">'. $this->get('ingredients'). '</div>
<div class="' .JText::_('amount'). '">'. $this->get('amount'). '</div>';
}
protected function _hasValue($params = array()) {
$ingredients = $this->get('ingredients');
$value = $this->get('ingredients');
$amount = $this->get('amount');
$value = $this->get('amount');
return !empty($ingredients) ||!empty($amount);
}
protected function _getValueList()
{
return array(
$this->get('ingredients'),
$this->get('amount')
);
}
}
Выводит ошибку:
Fatal error: Cannot redeclare ElementIngr::_hasValue() in Z:\
Сообщение отредактировал Ingvar: 13 June 2013 - 19:42
#8
Отправлено 13 June 2013 - 20:53
<?php /** * @package com_zoo * @author YOOtheme http://www.yootheme.com * @copyright Copyright (C) YOOtheme GmbH * @license http://www.gnu.org/licenses/gpl.html 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: ElementIngr The text element class */ class ElementIngr extends ElementRepeatable implements iRepeatSubmittable { /* Function: _hasValue Checks if the repeatables element's value is set. Parameters: $params - render parameter Returns: Boolean - true, on success */ protected function _hasValue($params = array()) { $value = $this->get('value', $this->config->get('default')); return !empty($value) || $value === '0'; } /* Function: _getSearchData Get repeatable elements search data. Returns: String - Search data */ protected function _getSearchData() { return $this->get('value', $this->config->get('default')); } /* Function: _edit Renders the repeatable edit form field. Returns: String - html */ protected function _edit() { $html = array(); $html[] = '<div>Ingredients</div>'; $html[] = $this->app->html->_('control.text', $this->getControlName('ingredients'), $this->get('ingredients', $this->config->get('default')), 'size="60" maxlength="255"'); $html[] = '<div>Amount</div>'; $html[] = $this->app->html->_('control.text', $this->getControlName('amount'), $this->get('amount', $this->config->get('default')), 'size="50" maxlength="150"'); } /* Function: _renderSubmission Renders the element in submission. Parameters: $params - AppData submission parameters Returns: String - html */ public function _renderSubmission($params = array()) { return $this->_edit(); } public function _render($params = array()) { return '<div class="' .JText::_('ingredients'). '">'. $this->get('ingredients'). '</div> <div class="' .JText::_('amount'). '">'. $this->get('amount'). '</div>'; } protected function _hasValue($params = array()) { $ingredients = $this->get('ingredients'); $value = $this->get('ingredients'); $amount = $this->get('amount'); $value = $this->get('amount'); return !empty($ingredients) ||!empty($amount); } protected function _getValueList() { return array( $this->get('ingredients'), $this->get('amount') ); } }Выводит ошибку:
Fatal error: Cannot redeclare ElementIngr::_hasValue() in Z:\
Изменил. теперь выводится , но в один столбик. и поиск не ищет по этим полям
.
вот код:
<?php
/**
* @package com_zoo
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl.html 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: ElementIngr
The text element class
*/
class ElementIngr extends ElementRepeatable implements iRepeatSubmittable {
/*
Function: _hasValue
Checks if the repeatables element's value is set.
Parameters:
$params - render parameter
Returns:
Boolean - true, on success
*/
protected function _getSearchData() {
$values = $this->_getValueList();
$result = JString::trim(implode("\n", $values));
return $result;
}
/*
Function: _getSearchData
Get repeatable elements search data.
Returns:
String - Search data
*/
/*
Function: _edit
Renders the repeatable edit form field.
Returns:
String - html
*/
protected function _edit() {
$html = array();
$html[] = '<div>Ingredients</div>';
$html[] = $this->app->html->_('control.text', $this->getControlName('ingredients'), $this->get('ingredients', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>Amount</div>';
$html[] = $this->app->html->_('control.text', $this->getControlName('amount'), $this->get('amount', $this->config->get('default')), 'size="50" maxlength="150"');
return implode("\n", $html);
}
/*
Function: _renderSubmission
Renders the element in submission.
Parameters:
$params - AppData submission parameters
Returns:
String - html
*/
public function _renderSubmission($params = array()) {
return $this->_edit();
}
public function _render($params = array()) {
return '<div class="' .JText::_('ingredients'). '">'. $this->get('ingredients'). '</div>
<div class="' .JText::_('amount'). '">'. $this->get('amount'). '</div>';
}
protected function _hasValue($params = array()) {
$ingredients = $this->get('ingredients');
$value = $this->get('ingredients');
$amount = $this->get('amount');
$value = $this->get('amount');
return !empty($ingredients) ||!empty($amount);
}
protected function _getValueList()
{
return array(
$this->get('ingredients'),
$this->get('amount')
);
}
public function _validateSubmission($value, $params)
{
if ((int)$params->get('required')) {
if (!JString::trim(implode(' ', $value->getArrayCopy()))) {
throw new AppValidatorException('Field is empty');
}
}
return $value->getArrayCopy();
}
}
#9
Отправлено 13 June 2013 - 21:13
Поиск будет искать по тем данным, которые возвращает функция _getSearchData
Отключайте проверку лицензий как можно скорее!
— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.
#10
Отправлено 13 June 2013 - 22:37
так у меня жу вроде как value присвоена двум моим полям.
Темы с аналогичным тегами подачи материалов
![]() |
Как создать сетку тегов для подачи материалов с фронтаАвтор Анастасия , 30 Jan 2014
|
|
|


Тема закрыта









