I'm writing an extBase extension but came to a problem with rendering records. Maybe I'm missing something, but if I did I guess I should be getting errors.
The code is part of the extension repository:
$conf = array(
'tables' => 'tt_content',
'source' => 21449, //actually here is variable for content uid but in given example i have this id
'dontCheckPid' => 1
);
$cObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer');
$cObject->cObjGetSingle('RECORDS', $conf);
var_dump returns an empty string, but I also tried this:
$cObject->RECORDS($conf);
and
$GLOBALS['TSFE']->cObj->RECORDS($conf);
resulting in an empty string, too.
When I check the database I find a record with that id, it's not hidden or deleted. The cType is textpic.
I suppose I could render it manually but that will be harder since I would have to write code for each cType we have in use.
Can anybody help here?
Maybe you should check extension called "vhs"? With it you will be able to render content elements with Fluid
Related
I have a problem. This code works when loading a tt_content element in my Controller from my Extenstion.
$cObj = $this->configurationManager->getContentObject();
$ttContentConfig = array(
'tables' => 'tt_content',
'source' => 123,
'dontCheckPid' => 1
);
var_dump( $cObj->RECORDS($ttContentConfig) );
But my problem is when I use a specific tt_content uid where an another plugin (foreign one, not from my extension) is connected in it then it don't output anything at all.
It's just giving me a string(50) with nothing in it, which is strange actually cause it should show something when there are 50 chars available :-(
But when I am using fluid then I'll get this INT_SCRIPT marker:
<!--INT_SCRIPT.061e018a9a1771fb1f9d0f4a0b71926b-->
Do I have to render this INT_SCRIPT in some way?
Or is there an another way to render the output so that the plugin in that tt_content element gets also rendered or something like this?
Thanks for helping me out and have a great day.
I'm using backpack 3.3 on a laravel 5.5 installation.
I want to prefill two create form fields with two URL passed values.
Say you create a basic backpack crud, named Image.
Normally you can go to domain/admin/image/create to view and fill in the form.
But if I add one or two params in the url, I get a 404.
I guess I should manage the routes file (admin.php)
I tried this way:
Route::group(['prefix' => 'image/{k}/{cid}'], function()
{
CRUD::resource('image', 'ImageCrudController');
});
but still get a 404.
Any suggestions?
Thanks in advance.
Almost all field types have a default option. So when you define them, you can specify a default. And you can always pass a GET parameter for that default. So you can have something like this in your EntityCrudController:
$this->crud->addField[ // Text
'name' => 'title',
'label' => "Title",
'type' => 'text',
'default' => \Request::has('title')?\Request::has('title'):false, // default value
]);
You'd then be able to send you users to yourapp/admin/entity/create?title=your+default+value and have that default value show up in the field.
Hope it helps. Cheers!
it works for me easier
http://127.0.0.1:8000/admin/resultado/create?competencia=2
$this->crud->modifyField("competencia_id",[
'label' => "Competencia",
"default"=>$this->crud->request->query->get('competencia'),
.....
I need a custom field to be FulltextSearchable. Therefore I tried this code as described in the FulltextSearchable class:
Object::add_extension('Page', "FulltextSearchable('SearchableContent')");
then run dev/build.
Basically Fulltext Search seems to work. But the content of the custom Field 'SearchableContent' seems never to be checked.
Of course I enabled FulltextSearch first by:
FulltextSearchable::enable();
Thx,
Florian
All SiteTree classes have their search columns define in FulltextSearchable like:
$defaultColumns = array(
'SiteTree' => '"Title","MenuTitle","Content","MetaTitle","MetaDescription","MetaKeywords"',
'File' => '"Title","Filename","Content"'
);
so I don't think SilverStripe will pick up on your extra column. Unless you edit the FulltextSearchable but that's probably a bad idea... or just create a custom search function like for plain DataObject so you can specify exactly which columns to search on:
silverstripe dataobject searchable
I want to upload multiple images using Zend_Form_Element_File with the HTML attribute multiple. Setting up the element works intuitively:
$form->addElement(new Zend_Form_Element_File(
'images',
array('label' => 'Images:', 'multiple' => 'multiple')
));
When I get a reference to the input field in my upload page und do a $input->receive(), it only saves one of the selected files.
When I search for something like "Zend_Form_Element_File multiple files", I only get results that show the use of Zend_Form_Element_File::setMultiFile(), which isn't what I'm looking for.
Any suggestions?
Just found the answer to my own question:
You have to set 'isArray' on the input element to true, either in the options array when constructing the element (new Zend_Form_Input_File('images', array('isArray' => true))) or via the isArray() method ($input->setIsArray(true)).
Some background info and how I finally found this solution:
First, I realized that I have to apend square brackets to the element's name for multiple file uploads to work, e.g. images[]. I don't know if that's the HTML specification or if that's something PHP requires, but that's how it should work in this case.
My next problem was that Zend_Form_Element removes the brackets when I try to set them with the name property. Finally, I stumbled upon the answer by Matthew Weier O'Phinney himself: isArray appends the [] for you.
I think this may be an easy solution, but I've spent an hour now investigating to no avail.
I have a registration form in an element that is being used in views belonging to different controllers. Using the "url" attribute, I've told it to submit to /users/register, but for some reason, the fields aren't submitting to the database.
Instead, there are errors for "undefined index" and a MySQL error for an undefined secondary key that I set (it's empty because it's not being submitted). Strangely, the form works fine if I include the element somewhere in the users views. Does anyone know why this is happening?
UPDATE - Here's the relevant code, sorry:
<?php
echo $form->create(array(
'id' => 'signupform',
'url' => array(
'controller' => 'users',
'action' => 'register')));
?>
The form fields are all correct, since the element works in the user controller's views anywhere. Do I need to include any other information in the creation of the form to point it more directly?
Specify the model 'User' as the first parameter to the $form->create() method.
<?php
echo $form->create('User', array(
'id' => 'signupform',
'url' => array(
'controller' => 'users',
'action' => 'register')
)
);
?>
This will ensure that the form fields are named as data[User][field_name], and prevent you from seeing that undefined index error.
Hope this works for you!
Without seeing the code, it sounds like Cake is magically assuming that the Model is the one for the controller that controls the current view. When that controller is Users, it works correctly. When it is, say, Articles, it will be trying (and failing) to fit the form fields to the Article model.
Without seeing any code, it is impossible to offer any more help.
EDIT:
If the form contains mixed models, e.g. User and Article, you must prefix the fieldnames like this:
$form->input('User.username');
$form->input('Article.title');
etc.
If you don't, the controller will assume they all belong to its own model.