Unknown record property / related component with multi refs to one table - symfony1

in model definition
$this->hasMany('Photo', array(
'refClass' => 'StyleLangHasPhoto',
'local' => 'style_lang_id',
'foreign' => 'photo_id'));
$this->hasMany('Photo as Preview', array(
'refClass' => 'StyleLangHasPreviewPhoto',
'local' => 'style_lang_id',
'foreign' => 'photo_id'));
but getter getPreview and even $this->_get('Preview') throws Unknown record property / related component "Preview" on "StyleLang"
i've try to make like this
$this->hasMany('Photo as Slide', array(
'refClass' => 'StyleLangHasPhoto',
'local' => 'style_lang_id',
'foreign' => 'photo_id'));
$this->hasMany('Photo as Preview', array(
'refClass' => 'StyleLangHasPreviewPhoto',
'local' => 'style_lang_id',
'foreign' => 'photo_id'));
but nothing changes
what i'm doing wrong?
UDP1: getPhoto, setPhoto, setPreview works good

problem was solved
foreignAlias: in relations for Photo and Preview must be different
thanx

Related

I want to list video from a list of channel

With youtube API, i would like to list video not only for one channel but from a list of channel,
with listSearch command it would be something like that ? but it's dont work ...
$searchResponse = $youtube->search->listSearch('id,snippet', array(
'maxResults' => _MAX_,
'type' => "video",
'order' => 'date',
"channelId" => "id_channel_1,id_channel_2, ..."
));

Custom elements in standard palette Contao

Iam using oneo custom elements .I need to add a field for content.Please check my code
<?php
return array(
'label' => array(
'en' => array('Feature boxe', 'Create an area with text, image/video and background image'),
'de' => array('Feature-Box', 'Erzeugt einen Bereich mit Text, Bild/Video und Hintergrundbild'),
),
'types' => array('content'),
'standardFields' => array('cssID', 'headline'),
'fields' => array(
array(
'inputType' => 'group',
'label' => array(
'en' => array('Image settings'),
'de' => array('Bildeinstellungen'),
),
),
'image' => array(
'label' => array(
'en' => array('Feature image or video', 'Choose an image or multiple video files.'),
'de' => array('Feature-Bild oder -Video', 'Wählen Sie ein Bild oder mehrere Videodateien aus.'),
),
),
);
The new field is appear in a new palette. But I need to add the new one in the same palette as cssID resides.Is it possible ???
I think you mean RockSolid Custom Elements. And no, that is not possible. Custom fields can only be added in the standard group of the custom element - or to custom groups that you define yourself.

Youtube Analytics API filters not working

I am trying to retrieve viewerPercentage based on gender, ageGroup filtering by country.
'ids' => 'channel=='.$channel->channel_id,
'start-date' => $monthAgo,
'end-date' => date("Y-m-d"),
'metrics' => 'viewerPercentage',
'dimensions' => 'ageGroup,gender',
'filter' => 'country=='.$country->code,
'access_token' => $tokens->access_token
The problem is that for each country it retrieves the same data. Therefore, for 50+ countries it gives the same data, which I don't think it is possible.
What I am doing wrong? Thank you
SOLVED
'filter' changed to 'filters'

Elastica multi_field setup

I'm trying to use multi_field syntax of elasticsearch in combination with Elastica. I create an index and an mapping which looks like this:
$mapping->setProperties(array(
'id' => array('type' => 'string', 'include_in_all' => true),
'title' => array('type' => 'string', 'include_in_all' => true),
'publisher' => array('type' => 'multi_field', 'include_in_all' => TRUE, 'fields' =>
array('publisherName' => array('type' => 'string', 'index' => 'analyzed'),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
));
So far, so good. I can run queries against the title field.
But when I try to query the field "publisher" in http://example.com:9200/_plugin/head/ I'm not able to select the field publisher or to create a structured query. I looks, that the field publisher is not in the index.
But I can build facets on publisher.untouched which works very well. Whats wrong in my mapping? I need to search for the publisher.
See the docs on multi_field mapping. Looks like you need to set a default field by changing 'publisherName' to just 'publisher'.

Symfony 1.4 can't get submitted files

must be some thing simply resolving, but as a beginner, i've already spend 2 days trying to find out. I'm having a simple form ("enctype="multipart/form-data") with few inputs of text and file. I can't get what's wrong, i can get user's text data through getParameter(), but cannot get file getFiles(). i'm on ubuntu 11.04 php5.3
code:
form class:
public function configure()
{
$this->setWidgets(array(
'vendor' => new sfWidgetFormInputText(array(), array('class' => 'form-text')),
'image' => new sfWidgetFormInputFile(array(), array('class' => 'form-text')),
'city' => new sfWidgetFormInputText(),
'email' => new sfWidgetFormInputText(array('default' => 'simple#sample.org')),
'contacts' => new sfWidgetFormTextarea(),
'description' => new sfWidgetFormTextarea(),
));
$this->setValidators(array(
'vendor' => new sfValidatorString(array('required' => false)),
'image' => new sfValidatorFile(array(
'required' => false,
'path' => sfConfig::get('sf_upload_dir') . '/images',
'mime_types' => 'web_images')),
'city' => new sfValidatorString(array('required' => false)),
'email' => new sfValidatorString(array('required' => false)),
'contacts' => new sfValidatorString(array('required' => false)),
'description' => new sfValidatorString(array('required' => false)),
));
$this->widgetSchema->setNameFormat('pv[%s]');
}
action:
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
return $this->renderText(var_dump($request->getParameter('pv'))); //this array include vars from form
//return $this->renderText(var_dump($request->getFiles('pv'))); //empty array
}
You should provide the actual code you are trying with. You could also look further into the forms component, which has a section on file uploads with example code here (bottom of page):
http://www.symfony-project.org/forms/1_2/en/02-Form-Validation
This part of the docs is still relevant for symfony 1.4.
Does your form widget configuration look anything like the following?
$this->setWidget('attachment', new sfWidgetFormInputFileEditable(array(
'file_src' => '/upload/' . $this->getObject()->getAttachment(),
'edit_mode' => true,
'with_delete' => true,
)));
$this->setValidator('attachment', new sfValidatorFile(array(
'path' => sfConfig::get('sf_upload_dir'),
'required' => false
)));
$this->setValidator('attachment_delete', new sfValidatorPass());
Also, check if you have permissions on your upload folder:
chmod 777 web/upload/
Are you binding the files as well as the form parameters, like so?
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
you must add the enctype="multipart/..." attribute to your form

Resources