I'm using the tx_news extension for Typo3. Therefore I'd like to disable some settings that are not used on my page, for instance categories:
I've already disabled them in the PageTS for the records like this:
TCEFORM {
tx_news_domain_model_news {
categories.disabled = 1
}
}
Removed them from the administration filters and columns:
tx_news {
module {
columns = istopnews,datetime,author
filters {
categories = 0
categoryConjunction = 0
includeSubCategories = 0
}
}
}
Now I'd also like to disable them in the plugin settings when adding the plugin to the page. in the BackendUtility.php I found the following lines who will do that for me (notice I've added categories categoryConjunction,..):
public $removedFieldsInListView = [
'sDEF' => 'dateField,singleNews,previewHiddenRecords,selectedList,categories,categoryConjunction,includeSubCategories',
'additional' => '',
'template' => ''
];
Of course like this I've already disabled the categories, but by directly editing the extension instead of overriding it from my own extension, that means when I update tx_news I will lose that configuration.
What $GLOBALS[TCA].. stuff do I have to add to get the same result? I can't find anything in the backend debugging...
I'm searching something like (or some TypoScript stuff if possible):
$GLOBALS['TCA']['tx_news_domain_model_news']['plugin']['backendUtility'][removeFieldsInListView]= 'bla, blabla, bla';
I appreciate all the help!
Have you tried some TsConfig like that
TCEFORM {
tt_content {
pi_flexform {
news_pi1 {
sDEF {
# Important is the escaping of the dot which is part of the fieldname
settings\.orderBy.disabled = 1
}
}
}
}
}
Related
I'm updating a TYPO3 v8.7 to TYPO3 10.4 LTS
In the TCA we have a pageType with a showitem of our choice. In v8 we used the following to have a custom view for a translated page eg. pages_language_overlay
$GLOBALS['TCA']['pages_language_overlay']['types'][$doktype] = array_replace_recursive(
$GLOBALS['TCA']['pages_language_overlay']['types'][$doktype],
[
'showitem' => '
myCustomShowItemString
'
]
);
Question: What would be the correct way to get have this behaviour again since pages_language_overlay does not exist anymore?
as the translated pagesrecords also are pages records you need this configuration for the table pages.
either you have it already, as your new doktype behaves the same for each language
or you need a special handling if sys_language_uid is not 0.
Then you probably need display conditions for those fields which behave different depending on sys_language_uid (this one visible, others invisible?)
TCA - file which has to be loaded after custom fields
$disableOnLanguageOverlay = [
'my_tca_field',
'my_tca_field',
];
foreach ($disableOnLanguageOverlay as $field) {
if (isset($GLOBALS['TCA']['pages']['columns'][$field])) {
$GLOBALS['TCA']['pages']['columns'][$field] = array_merge($GLOBALS['TCA']['pages']['columns'][$field], ['l10n_mode' => 'exclude']);
}
}
And for Typoscript
[siteLanguage("languageId") != 0]
TCEFORM {
pages {
myField {
disabled = 0
}
}
}
[global]
Solved above
I've created a custom page devis and its controller in Prestashop 1.6, but I'm unable to display any columns.
Controller :
class DevisController extends FrontController
{
public $php_self = 'devis';
public $display_column_left = true;
...
}
In Theme configuration, my 'Devis' page appears and the left column is checked :
The "display or not" logic happens in FrontController.php's constructor :
if (isset($this->php_self) && is_object(Context::getContext()->theme)) {
$columns = Context::getContext()->theme->hasColumns($this->php_self);
// Don't use theme tables if not configured in DB
if ($columns) {
$this->display_column_left = $columns['left_column']; // FALSE : why ?
$this->display_column_right = $columns['right_column'];
}
}
I can force the column to display by doing $this->display_column_left = true but it's obviously not the way to do it.
Does someone know why $columns['left_column'] is false ?
Sh*t...
As mentionned by #julien-lachal, the issue was shop-level related.
That means I was browsing the dashboard as "All the shops".
By choosing the desired shop, the left column in theme settings was actually disabled.
Big problems simple fixes...
I have the below function to create active trail functionality. So if I were to have /blog as a "parent" and a post of /blog/mypost, when on mypost the blog link would show as highlighted. I don't want to have to make menu items for all the blog posts. The problem is when caching is turned on (not using settings.local.php and debug turned off) the getRequestUri isn't changing on some pages. It seems to be cached depending on the page. It works fine with page caching turned off but I'd like to get this working with caching. Is there a better way to check for the current path and apply the active class?
function mytheme_preprocess_menu(&$variables, $hook) {
if($variables['theme_hook_original'] == 'menu__main'){
$node = \Drupal::routeMatch()->getParameter('node');
if($node){
$current_path = \Drupal::request()->getRequestUri();
$items = $variables['items'];
foreach ($items as $key => $item) {
// If current path starts with a part of another path i.e. a parent, set active to li.
if (0 === strpos($current_path, $item['url']->toString())) {
// Add active link.
$variables['items'][$key]['attributes']['class'] .= ' menu-item--active-trail';
}
}
}
}
}
I've also tried putting this into a module to try and see if I can get the current path to then do the twig logic in the menu--main.twig.html template but I have the same problem.
function highlight_menu_sections_template_preprocess_default_variables_alter(&$variables) {
$variables['current_path'] = $_SERVER['REQUEST_URI'];
}
After a very long time trying all sorts of things, I found an excellent module which addresses exactly this problem. Install and go, not configuration, it just works:
https://www.drupal.org/project/menu_trail_by_path
Stable versions for D7 and D8.
I tried declaring an active path as part of a custom menu block, and even then my declared trail gets cached. Assuming it's related to the "There is no way to set the active link - override the service if you need more control." statement in this changelog, though why MenuTreeParameters->setActiveTrail() exists is anybody's guess.
For the curious (and for me when I search for this later!), here's my block's build() function:
public function build() {
$menu_tree = \Drupal::menuTree();
$parameters = new MenuTreeParameters();
$parameters->setRoot('menu_link_content:700c69e6-785b-4db7-be49-73188b47b5a3')->setMinDepth(1)->setMaxDepth(1)->onlyEnabledLinks();
// An array of routes and menu_link_content ids to set as active
$define_active_mlid = array(
'view.press_releases.page_1' => 385
);
$route_name = \Drupal::request()->get(RouteObjectInterface::ROUTE_NAME);
if (array_key_exists($route_name, $define_active_mlid)) {
$menu_link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(array('id' => $define_active_mlid[$route_name]));
$link = array_shift($menu_link);
$parameters->setActiveTrail(array('menu_link_content:' . $link->uuid()));
}
$footer_tree = $menu_tree->load('footer', $parameters);
$manipulators = array(
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
);
$tree = $menu_tree->transform($footer_tree, $manipulators);
$menu = $menu_tree->build($tree);
return array(
'menu' => $menu,
);
}
[adding a new answer since this is a completely different approach than my earlier one]
If a CSS-based solution is acceptable, this seems to work okay:
.page-node-type-press-release {
a[data-drupal-link-system-path="press-room/press-releases"] {
// active CSS styles here
}
}
Running Joomla 3.3.0-dev
I'm following the info posted here about adding tag support to a third-party component.
I've added the content type to the #__content_types table and modified my table file like this:
class MycomponentTableElement extends JTable
{
public $tagsHelper = null; // failed when protected and public
public function __construct(&$_db)
{
parent::__construct('#__mycomponent', 'id', $_db);
// Add Joomla tags
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'MycomponentTableElement', array('typeAlias' => 'com_mycomponent.element'));
//$this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this); // failed with or without this line
}
I added the tag field in the edit template, and it worked fine-- but when I save an object I get the following error:
Save failed with the following error: Unknown column 'tagsHelper' in 'field list'
What am I missing? There's no other steps (besides front-end steps!) that are mentioned. It seems like I need to modify the model but that info is not applicable.
Thanks
"This Page Needs Copy Editing" and it's really true!
I also follow initial steps as described in page
Register a 'Content type' for the extension view(s)
Add 'Observer methods' to the extension table class(es)
Add 'Tag fields' to the extension edit forms
But to make field tag works on custom extensions I need to explicit set form field value in view file of backend:
$tagsHelper = new JHelperTags;
$this->form= $this->get('Form');
$this->form->setValue('tags', null, $tagsHelper->getTagIds( $this->item->id, 'com_custom.viewname') );
in this way on edit page all seems to work correctly.. surely exist better and more clean method, but until doc page will not be updated, this can help someone!
1- Add tag field to your xml form file or edit template file
2- Modify #__content_types table file:
function __construct(&$db)
{
parent::__construct('#__ir_products', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_itemreview.product'));
}
3- Modify model file getItem function:
public function getItem($pk = null)
{
$item = parent::getItem($pk);
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_yourcomponent.yourmodel');
}
return $item;
}
I am using drupal 7. First please refer my screen shot to get what i am talking about.
http://www.karya.gisla.in/scr.png
Lets say my content type is article. when we create a article, for authenticated users, the node displayes primary tabs namely : View and Edit. I just want to change/edit it to say :View Article and Edit Article.
Note: Just for a specific content type only. i.e other content type say Page will display as default : View and Edit.
Any ideas how to achieve this.
Any help will be appreciated.
The following code does the trick. Paste it in your themes template.php and change YOURTHEMENAME to... your theme's name.
maybe use dpm($vars) in this function to have a look which kinds of information in $vars is. This should help you getting to the point even faster next time.
[EDIT:]
Thanks Ben for pointing that out!
Here's an updated version:
function YOURTHEMENAME_preprocess_page(&$vars) {
if ($vars['node']->type == 'article') {
foreach($vars['tabs']['#primary'] AS $index => $tab) {
if($tab['#link']['title'] == t('View')) {
$vars['tabs']['#primary'][$index]['#link']['title'] = t('View Article');
}
if($tab['#link']['title'] == t('Edit')) {
$vars['tabs']['#primary'][$index]['#link']['title'] = t('Edit Article');
}
}
}
}
Have fun, Martin
The String Overrides Module may help, though I'm not sure if it handles roles.
You can place the following function into the template file of your theme and replace YOURTHEME with the theme name to alter the tab links.
$nodes is a multidimensional array in which the first level of keys are the content types you wish to replace tabs on and the second level of key value combinations are path and replacement pattern respectively. Setting a replacement pattern as '' will remove the tab.
/**
* Implements hook_menu_local_tasks_alter().
*/
function YOURTHEME_menu_local_tasks_alter(&$data, $router_item, $root_path) {
$nodes = array(
'article' => array(
'node/%/view' => 'View Article',
'node/%/edit' => 'Edit Article'
)
);
foreach ($router_item['page_arguments'] as $key => $argument) {
if (is_object($argument) && array_key_exists( $router_item['page_arguments'][$key]->type, $nodes )) {
foreach( $nodes[$router_item['page_arguments'][$key]->type] as $path => $new_title ) {
foreach ($data['tabs'][0]['output'] as $key => $value) {
if ($value['#link']['path'] == $path) {
if( !$new_title ) {
unset($data['tabs'][0]['output'][$key]);
} else {
$data['tabs'][0]['output'][$key]['#link']['title'] = $new_title;
}
}
}
}
}
}
}
There is a module for that:
https://drupal.org/project/tabname_tweaker
;-)