Sorting of Sys Categories - typo3

How can I sort alphabetically in the backend of TYPO3 system categories . Here UID seems to be preset .
Currently, main and sub-categories are listed in order of their creation .

Create a PHP file inside your sitepackage EXT:my_sitepackage/Configuration/TCA/Overrides/sys_category.php
with following content
<?php
defined('TYPO3_MODE') or die();
$GLOBALS['TCA']['sys_category']['ctrl']['sortby'] = null;
$GLOBALS['TCA']['sys_category']['ctrl']['default_sortby'] = 'ORDER BY title';
to override default settings

Related

TYPO3 how to modify TCA?

TYPO3 9, but is probably independent of TYPO3 version
I have installed news and eventnews. eventnews adds a field location_simple to the table tx_news_domain_model_news. In the backend this is of type input. I want it to be of type text. Therefore I added a file Configuration/TCA/Overrides/tx_news_domain_model_news.php to my sitepackage:
<?php
if( !defined('TYPO3_MODE') ) {
die ('Access denied.');
}
// Modify location simple
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['location_simple']['config']['type'] = 'text';
But this has no effect.
My sitepackage is included at last position, so it should be able to overwrite the TCA of eventnews. What is correct the magic for this?
This worked for me: rename my site package extension so that it has an extension key alphabetically after 'e'.
It seems as if the files in /Configuration/TCA/Overrides are read alphabetically. In my case I wanted to override eventnews. So my site package extension key had to begin with a letter in [f-z].

List view new record category label name TYPO3

I create some custom content elements with tt_content, typoscript and tsconfig etc. in a config extension. All works nice.
When changing to list view my custom content element gets listed under 'pen', which seems to be derived from either the extensionname or a table.
How can I set this name? See image.
You're right that the shown text depends on the table indirectly.
Here is the essential code shown how the name is determined depending on the table-configuration in TCA:
$temp = explode(':', substr($v['ctrl']['title'], 9 + strlen($_EXTKEY)));
$langFile = $temp[0];
$thisTitle = $lang->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
This snippet is copied from the file typo3/sysext/backend/Classes/Controller/NewRecordController.php in the method renderNewRecordControls().
So in the end the text is determined in the language file(s) of your extension.

Magento 2 - How to loop all categories and load category image?

I'm building a theme for Magento 2. The homepage needs to loop through all the categories and output the category name, url and the image uploaded to the category within the admin within the .phtml file.
Is this possible and how can I achieve this?
Thanks in advance :)
I hope following code will help you.
We have used direct object manager. Please use this code in your phtml file and run anywhere.
<?php
//create a phtml file or write this code in any phtml file and use where you want
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$categoryCollection = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory');
$categoryHelper = $objectManager->get('\Magento\Catalog\Helper\Category');
$categories = $categoryHelper->getStoreCategories();
foreach ($categories as $category) {
//print_r($category->getData()); ?>
<?php echo $category->getName() ;?>
<?php }?>
Please check this link also -http://blog.chapagain.com.np/magento-2-get-parent-category-children-categories-product-count/

How to call specific Static Blocks inside product descriptions in Magento?

I tried adding a static block to my product description by adding the following code to my description page:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('description02')->toHtml() ?>
This works. But what can I do if I want to use different static blocks for different products? I don't want the same static block to show on all products. Is there way that I can choose which static block shows?
Thanks!
You can proceed as follows :
Create a new text type product attribute from Catalog -> Attributes and add it in used Attribute set from Catalog -> Attribute sets
After this you can add different static block names into this field while adding/editing products.
On product details page use the same you are using above, just make the static block to fetch name from the above created attribute.
Hope this will help.
UPDATE
Lets suppose you created a new attribute named "static_block" then go to Attribute sets, click on the set you are using for the product you want to show the block into.
Drag and drop the static_block from the unassigned to assigned attribute and save Attribute set.
After this create multiple static block block for ex : block_1, block_2
Edit product and in the field assigned above enter block_1 or block_2
After this on product description template i.e catalog/product/view.phtml add code as per following example :
<?php
$blockId = $_product->getData('static_block');
OR
$blockId = $_product->getStatic_block();
Whichever works
echo $this->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml() ?>
you may need to tweak in above code as i have not tested this.
Hope this helps.
1) Create Attribute caller for example static_block_description_code
2) Attach this attribute to proper Attributes Set in Admin section too (set, which You use for you're desired product)
3) go to (in my example) app/design/frontend/PACKAGE/default/template/catalog/product/view/description.phtml and search line responsible to display standard description
I have:`
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
</div>`
and i've changed it to `
<div class="std block-description">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($block_description)->toHtml() ?>
</div>`
On top of this file I've added:
<?php $_product = $this->getProduct(); ?>
<?
$block_description = $_product->getData('static_block_description_code');
?>

Symfony dynamic model form template

I am developing symfony based web application. I have many Models (Laptop, Netbook, Ipad,Tablet.... all these models inherited from Product model).Based on these models I also have Forms (LaptopForm, NetbookForm...so on).
In my action class I get Model name and assign it to template :
$modelForm = $this->modelName.'Form';
$this->form = new $modelForm();
Then in my template I do that <?php echo $form ?> ..There is no problem it prints all fields and labels in html table.
But my problem is that I want to divide template in to 2 parts. General and special fieldset.In general fields set i want to display Product model fields(name,price...).But Special field set changes according to product type. How I can handle this special fields set?Can someone give a clue or source please?
Thanks in advance!
You can manage it manually, in your specialized form class (not alter the base class).
Perhaps, with the use of sfWidgetFormSchema :
http://www.symfony-project.org/forms/1_4/en/A-Widgets#chapter_a_sfwidgetformschema
You have to name the widget 'general' and 'special', for a stanhdard re-use in form template, like this :
<?php echo $form['general'] ?>
<?php echo $form['special'] ?>