TYPO3 TCA, hide tab in translated item - php

In my Extension I create several tabs for the backend with --div--, the code looks something like this:
'types' => array(
'0' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1,--div--;My Tab, title, category,
),
While there is an easy way to hide a single field in the translated item with: 'displayCond' => 'FIELD:sys_language_uid:=:0',, I have no idea how to hide a whole tab.
Does anybody know how I have to write the 'types' array to hide "My Tab" in the translation records? Thank you in advance.
Edit (Solution):
Using config as stated in the answer is possible, but there is another way I discovered by accident: If you hide all fields that are associated with a tab with 'displayCond' => 'FIELD:sys_language_uid:=:0', the tabs will also be hidden.

I think you may need to use tsconfig.
Please check the section: "New content element wizard (mod.wizards.newContentElement)" in this link: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsconfig/4.3.2/view/1/5/

Related

Wordpress CMB2 show-on page template - default page template

I am using CMB2 and would like to only show a particular CMb2 metabox on the default page template. I have tried passing a value of page.php as the value of the show-on filter but its not working. Any ideas welcome? I could write my own custom show-on filter but I am sure the functionality must already exist.
It's been a while, so maybe you've found the answer. But since I've been looking myself as well, let me post the result here for future reference.
The solution is simply, instead of 'page.php', just use 'default' as the value for the show-on filter:
'show_on' => array( 'key' => 'page-template', 'value' => 'default' )
#ruude3 answer works. Also you'll need to either save the new page as a draft or publish it before the meta fields will appear.

Get Wordpress/ACF options on child pages

I use Wordpress with Timber (as template renderer), and Advanced Custom Fields. I'm struggling with some sub page options.
My problem is that I can't get the options on the right posts (my jobs) – it's only available on the job overview page.
I've created an options sub page to my custom post_type "job", like so:
if (function_exists("acf_add_options_page")) {
acf_add_options_sub_page(array(
"page_title" => "Job options",
"menu_title" => "Job options",
"menu_slug" => "job_options",
"capability" => "edit_posts",
"parent_slug" => "edit.php?post_type=job"
));
}
And I'm able to get that options on the job-overview page, like so:
$context["options"] = get_fields("options");
But when I run that same command on the posts with post_type "job", then it returns null.
How can I get that options to affect the posts with post_type "job" and not the overview?
** EDIT **
Okay, so I found out that somehow it had worked, since I could get SOME of the options, and I could edit them in ACF, but I couldn't add new options. Somehow the link to "options" is broken. I have no idea how to fix this.
This was a bug in version 5.3.2.
This has been fixed in version 5.3.2.1.

Yii2 Advanced Template Calendar Widget: Display events from database

I'm using yii2-fullcalendar widget and I used thiagotalma's post on github as a guide for the installation of the calendar widget. Below is the code that I've used to display the calendar on the page:
<?= \talma\widgets\FullCalendar::widget([
'googleCalendar' => true, // If the plugin displays a Google Calendar. Default false
'loading' => 'Carregando...', // Text for loading alert. Default 'Loading...'
'config' => [
// put your options and callbacks here
// see http://arshaw.com/fullcalendar/docs/
'lang' => 'en-ca', // optional, if empty get app language
],
]); ?>
and the above code displays the calendar on the web page. Now, I want to display the events from database but I don't have any idea how to do it. Can anyone help me regarding this matter? Thanks in advance.
You might want to look into my calendar view widget, looks like it's bang on. Takes data from your model and puts them into a responsive calendar.
I am the author btw. Should be simple enough if you read through the readme, it's step by step.

how to make an unclickable/disabled/grey list item in yii

Inside layout>main.php i have this
array('label'=>'Appointment',
'items'=>array(array('label'=>'Appointment(Office)','url'=>array('/appointOffice')),
array('label'=>'Appointment(User)','url'=>array('/appointUser')))),
I want to make one of the items unclickable for a specific type of users. example: office users cant click Appointment(User). Can anyone explain a bit how to disable an item? I am using MbMenu extension. Just to mention, i don't want to hide the item, i want make it disable.
Just for the record, here's the corrected answer;
You need to have some logic in place to decide whether to display a link or not.
array('label'=>'Appointment',
'items'=>array(array('label'=>'Appointment(Office)','url'=>array('/appointOffice')),
array('label'=>'Appointment(User)','url'=>!User->isOfficeUser() ? array('/appointUser') : ''))),
http://www.yiiframework.com/doc/api/1.1/CMenu#items-detail
linkOptions: array, optional, additional HTML attributes to be rendered for the link or span tag of the menu item.
itemOptions: array, optional, additional HTML attributes to be rendered for the container tag of the menu item.
So, 'linkOptions' => array('disabled' => Yii::user()->group == 'groupForDisabledLink').
// upd
BTW, better use routes rather than direct url, via 'url' => array('controller/action').

Drupal node 2-page content split

My employer requires certain pages on the website have a two page feature.
What this means is that some default content show up on the node_view page as normal but the second part should show up when a link is clicked.
This will be easy if I could do this across multiple nodes but the requirement is for all the data to be stored in one node but displayed across two pages.
I hacked together the following code:
function mymodule_node_view($node, $view_mode, $langcode){
$path = current_path();
$path_alias = drupal_lookup_path('alias',$path);
$links = array( 'test' => array('title'=>'my_link', 'query'=>'', 'href'=>"{$path_alias}/nextpage") );
$node->content['my_module'] = array(
'#theme' => 'links__node__mymodule',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
That creates a hyperlink called my_link across the top of my content area - which is great.
The problem starts when I click the hyperlink. Supposing I am on http://example.org/homepage and I click the hyperlink, I expect to be redirected to http://example.org/homepage/nextpage. Also, I still want to maintain the view and edit tabs of the actual node I was on. However, Drupal correctly gives me a "page not found" error.
What's interesting is if I used http://example.org/node/1 and visited http://example.org/node/1/nextpage, I don't get the issues I described above but the url is less descriptive.
To solve this problem, I am sure I have to extend hook_menu but I don't know how to account for any number of taxonomy terms leading up to the actual node title. So, I can't predict how many % I will need before the node title and then my /nextpage. However, I want /nextpage to still have the view and edit tabs of it's parent page.
This is all unexplored territory for me.
Update
I found the following function which does a great job of returning the entire node path complete with taxonomies:
$path = current_path();
$path_alias = drupal_lookup_path('alias',$path);
What I don't know is how to take advantage of this in hook_menu to dynamically create /nextpage for my nodes.
Please remember, I don't really want /nextpage to be entirely independent of the original and actual Drupal node. When on /nextpage I want to be able to have access to the view, edit etc tabs of the node.
So, /nextpage effectively is just an extension of a Drupal node page.
There is a quick way to do that. Using views module.
In the fields section choose the field you wanna view. And in the arguments add the nid.
Then add the link to the node view you already created.
The final result http://mysite/views-page/[nid]
Hope this helps... Muhammad.
I would check the node_menu() function to get some reference on how it's implemented.
Not sure on your taxonomy requirements so this might be insufficient but I'll go with what I understand.
But off the top of my head I'd go for something like:
function mymodule_menu() {
$items['node/%node/nextpage'] = array(
'title' => 'Next page',
'type' => MENU_LOCAL_TASK, // Makes it a tab on node/%node-pages
'page callback' => 'mymodule_node_page_view', // Your page display function
'page arguments' => array(1), // First will be a node object, second will be whatever value is passed in the url
// You should rip access callback and access arguments from node_menu()
);
return $items;
}
That should do something like what you are asking for.
It is also possible, easier and definitely recommended to do this with Panels/Pages (see also Chaos Tools) or arguably Views as they are quite capable of all this and generally a better way to work with Drupal's strengths than custom code.
Updated
To clarify I've simplified the menu hook and you should be able to use the below page view function. I still believe you would make a better solution using Panels and overriding node_view and such.
The MENU_LOCAL_TASK part in the menu hook should turn this into another tab along with View and Edit.
function mymodule_node_page_view($node) {
die("It works: ".$node->title);
}
Hope that's more helpful.

Categories