TYPO3 backend: search custom records - search

I developed an extension which allows creation of new records.
In List module, under the records list, there is the Search form.
It works with fe users for example, but not with my custom records.
Is there any special configuration that I have to add in my tca to make this form work with my custom records?
EDIT: This seems to be happening after updating to TYPO3 4.6. In the previous version, 4.3.3, it works.
Thanks.

Edit ext_tables.php file in typo3conf/ext/yourext directory, find your table, and add to its ctrl section searchFields property as comma separated list of fields to search in:
$TCA['tx_yourext_table'] = array(
'ctrl' => array(
'title' => 'Title of your table',
'label' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
// etc...
'searchFields' => 'title, other_field, yet_other_field',
),
);
Don't forget to clear all caches after that, works at 4.6.3
There's official information when and why it was changed

Related

Netsuite Multiple inserts of Address on Customer Record

We are using the REST API to Upsert customer record. Included in the PUT is the address record.
Everytime we send the PUT, the customer record is updated as expected. The problem is that every time we run the request, a new address is added to the address book.
"companyName"=> $result['CLIENTNAME'],
"email"=> '',
"emailPreference"=> "PDF",
"emailTransactions"=> false,
"externalId"=> $netsuiteCustomerId,
"isinactive"=> false,
"phone"=> $result['TELEPHONENO'],
"subsidiary"=> ["id"=> "2"],
"terms"=> ["externalId"=> "PTTRM".$result["TERMID"]],
"vatRegNumber"=> $result['ABN'],
"addressbook" => array(
"items" => array(
array(
"label"=> $address['addr1'],
"addressbookaddress" => $address = array(
"addr1" => $result['ADDRESS1'],
"addressee" => $result['CLIENTNAME'],
"addrText"=> $result['ADDRESS1']."\n".$result['ADDRESS2'],
"externalId" => 'ADDR_'.$netsuiteCustomerId,
);
)
)
)
Adding the externalId to the address doesn't appear to work. We have multiple addresses with the same ID. The SOAP API allows a replaceAll attribute, but that doesn't exist on the REST API.
I haven't tried doing this myself but you may want to check the documentation again (https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSTRW/NSTRW.pdf). It shows samples of replacing sublists using 'replace' in the query parameter.
The REST API browser also mentions 'replace' under request parameters.
You need to use PATCH instead of PUT to update the address

KNEX: How to get nested data from foreign key using join?

I've been trying to structure a fetch call with a query to return joined data between the two tables in my database. I have one table for projects, and another for palettes that includes a foreign key of "project_id".
Below is one of many iterations I've tried so far that isn't working (it's probably a total mess by now). I tried a join for a while and then totally gave up, because fields with the same name were overwriting each other.
I also couldn't figure out how to get the palette data nested inside the project data, which would also resolve the issue of names overwriting. Finally I got to this point, just forgetting joins altogether and trying to manually structure the output, but I don't get data back or even any error message.
.select()
.then(projects => {
return projects.map(async project => {
return database('palettes')
.where({ project_id: project.id })
.then(palettes => ({ ...project, palettes }))
})
}).then(projects => res.status(200).json(projects))
.catch(error => res.status(500).json({ error }))```
You did not provide your database type and schema structure.
Assuming: projects (project_id, name), palettes (palette_id, name, project_id)
and that you want to find all projects with a 1:1 relation to their palette this should suffice:
knex
.select(
'projects.project_id',
'projects.name as project_name',
'palettes.palette_id',
'palettes.name as palette_name'
)
.from('projects')
.innerJoin('palettes', 'projects.project_id', 'palettes.project_id')

How do I search related values in Yii2?

I have the following situation in Yii2:
Project model
CustomField, defining a custom field type and whether it should be applied to Projects (other options are employees and companies)
CustomFieldContent, related to both an entity (project in this case) and a custom field type
So, an example:
Project with id 1
CustomField with id 2
CustomFieldContent with entityId = 1, type = 'project', customFieldId = 2 and value = 'test'
Now, displaying custom content for each project in Yii's gridview is no problem. But, I want to make it searchable and sortable. Therefore, I need to add the custom field name as an attribute to ProjectSearch. That, however, can't be done as Yii doesn't allow for dynamic attributes.
Any ideas as to how to go about this?
For searchable and sortable content i suggest you this tutorial where you can find useful sample for build what you need. ( the scenario nuber 2 is the more appropriate to your needs)
In short term, you should extend your base model adding the relation you need, setup in searchModel proper functions adding to the dataProvider->setSort for the field/relation and add the where condition for filtering.
below a short extract
$dataProvider->setSort([
'attributes' => [
....
'yourRelatedField' => [
'asc' => ['field1' => SORT_ASC, ],
'desc' => ['field1' => SORT_DESC,],
'label' => 'your Laber',
'default' => SORT_ASC
],
]
]);
and extending the where condition for filtering.
/* Add your filtering criteria */
// filter CustomFieldContent
$query->joinWith(['table_a' => function ($q) {
$q->where('table_a.CustomFieldContent LIKE "%' . $this->CustomFieldContent . '%" ');
}]);

Kohana 3: Validation rule for has_many through relationship

Is it possible to create a validation rule in Kohana 3 that will validate the has_many through relationship?
Using the example on the guide page, a blog post can have many categories through the categories_posts table. Is there a validation rule that can be setup in the Post model to verify at least one category was added?
I tried the following:
public function rules()
{
return array(
'categories' => array(
array(array($this, 'has'), array('categories'))
)
);
}
because I see that the ORM::has function will return true/false. But I think because 'categories' is a relationship, and not a field, the rule I wrote never gets checked.
Any ideas?
You must save Post before adding has_many relations. You can check Post for categories after saving, and mark it as draft if they were not set.
Woo, good idea.
Focus in MVC design pattern. I think that's C business not the M.
if ($post->categories->find_all())
{
//blablabla
}
Since categories is external to the posts table, you'll want to use external validation. Create a function called Model_Post::rule_has_valid_categories($submitted_categories, $post) that returns a boolean denoting whether or not the submitted categories are valid for this post.
Then, create the extra rule just before you try to save the post:
$extra_rules = Validation::factory(array('categories' => $submitted_categories))
->rule(
'categories',
'Model_Post::rule_has_valid_categories',
array(':value', ':model')
);
try
{
$post->save($extra_rules);
}
catch (ORM_Validation_Exception $e)
{
// if categories rule failed, array will contain _external[categories] field
print_r($e->errors('models'));
}
You store the message in /application/messages/models/post/_external.php:
return array(
'categories' => array(
'Model_Post::rule_has_valid_categories' => 'Invalid categories'
),
);

SMF moderators can change their post count

I have an SMF forum currently running on SMF 2.0RC4 and the moderators can change their post count. This is not a big problem as it's only available for the mods, but still I would like to know where I can change this. I found some settings in permissions settings, but when disabled, they could not change anything in the profile.
You can hack your way out of it.
In ./Sources/Profile-Modify.php on line 568
'posts' => array(
'type' => 'int',
'label' => $txt['profile_posts'],
'log_change' => true,
'size' => 7,
'permission' => 'moderate_forum'
Change 'permission' => 'moderate_forum' to 'permission' => 'admin_forum'.
Then only admins can edit the post count.

Resources