I have a Tabs widget:
echo Tabs::widget([
'items' => [
[
'label' => 'Add Staff',
'icon' => 'user',
'content' => "Add Staff page loaded here",
'active' => true
],
[
'label' => 'Store Configuration',
'content' => 'Store Configuration page loaded here',
//'headerOptions' => [...],
'options' => ['id' => 'myveryownID'],
],
[
'label' => 'Transaction',
'items' => [
[
'label' => 'Add Transaction',
'content' => 'Add Transaction page loaded here',
],
[
'label' => 'View Transaction',
'content' => 'View Transaction page loaded here',
],
],
],
],
]);
How do I render a page (without reloading the entire page, if possible) inside a Tab content? Is it possible? I tried this:
'content' => "<?= $this->render('createbizstaff', ['searchModel' => $searchModel,'dataProvider' => $dataProvider,]); =>"
But it only generates this error:
Getting unknown property: yii\web\View::render
If you have any idea how to deal with this, please let me know.
You are trying to pass a PHP expression where a string is required. yii\web\View::render() returns a string so your code should read:
'content' => $this->render('createbizstaff', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]),
try using Pjax widget. you can load a part of that content without reloading the whole page. but it will reload the whole page when it reach its timeout and it is still loading.
check this guy's tutorial. http://blog.neattutorials.com/yii2-pjax-tutorial/
Related
I created a custom content element with TYPO3 ver. 10.4.21, but I have a problem.
Problem: showing up same Fields on every edit page of content elements.
I want to use own fields only on my custom content element (for my flipbox-content element). But if I select e.g. a regular text element, then I can see my own fields on the edit page by the text element too.
I wrote the codes in TCA/Overrides/tt_content.php:
###############################################
# Front side #
###############################################
// front side header
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_frontsideheader' => [
'exclude' => 0,
'label' => 'Front side header',
'config' => [
'type' => 'text',
'renderType' => 'input',
'items' => [
[
0 => '',
1 => ''
]
],
],
],
]
);
// front side bodytext
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_frontsidebodytext' => [
'label' => 'Front side bodytext',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 15,
'enableRichtext' => true,
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'general',
'tx_pagesaddfields_frontsideheader, tx_pagesaddfields_frontsidebodytext',
'after:tx_container_parent'
);
###############################################
# Back side #
###############################################
// back side header
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_backsideheader' => [
'exclude' => 0,
'label' => 'Back side header',
'config' => [
'type' => 'text',
'renderType' => 'input',
'items' => [
[
0 => '',
1 => ''
]
],
],
],
]
);
// back side bodytext
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_backsidebodytext' => [
'label' => 'Back side bodytext',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 15,
'enableRichtext' => true,
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'general',
'tx_pagesaddfields_backsideheader, tx_pagesaddfields_backsidebodytext',
'after:tx_pagesaddfields_frontsidebodytext'
);
I know because I wrote "addTCAcolumns('tt_content'). But I don't know how I can rewrite them to let show up my new fields only on my custom edit page.
Is it the right page to chage it?:
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ExtendingTca/Examples/Index.html
(by exanple1) and
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/User/Index.html#columns-user?
I tried to do it, but it didn't work on my site. Unfortunately, I don't have enough experiences with PHP... If you know other website or if you can explain here, please write it down here.
I hope anyone can help me. Thank you.
It is best practice to add one file into TCA/Overrides/ per custom content element. The name is up to you, TYPO3 reads all .php files in this folder. content_element_<your_ctype>.php or tt_content_<your_ctype>.php are used as name quite often.
https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TCA/Overrides/203_content_element_card_group.php
Here you can see how it is done in the bootstrap_package for the custom content element with the CType card_group
In line 42 $GLOBALS['TCA']['tt_content']['types']['card_group'] the configuration is limited to ['(C)type']['card_group'] and the 'showitem' => ' tells TYPO3 what and how to show fields for this content element.
From line 70 on you can see how to set a new field, in line 49 you can see how it was added.
I have created an interactive message button to open up a dialog.
This is the application code to the interaction message end-point.
$httpClient = new GuzzleHttp\Client();
$httpClient->post($interactionRequest->payload->response_url, [
'json' => [
'text' => 'dialog open',
'trigger_id' => $interactionRequest->payload->trigger_id,
'dialog' => [
'callback_id' => 'ryde-46e2b0',
'title' => 'Request a Ride',
'submit_label' => 'Request',
'elements' => [
[
'type' => 'text',
'label' => 'Pickup Location',
'name' => 'loc_origin',
],
[
'type' => 'text',
'label' => 'Dropoff Location',
'name' => 'loc_destination',
],
],
],
],
]);
Request succeed and the message I have defined in the json text attribute is shown in the slack. But the dialog doesn't open.
What is the missing part of my code, to open up a dialog?
This does not work, because you are not using the correct approach for opening a Dialog.
If you want to open a Slack dialog you need to post the dialog definition along with the trigger to this API method: dialog.open.
I'm currently using the drsdres/yii2-wizardwidget and wanted to modify the icon which shows at the top of the wizard (the round tabs). Here is my wizard config variable setup
$wizard_config = [
'id' => 'stepwizard',
'steps' => [
1 => [
'title' => 'Step 1',
'icon' => 'glyphicon glyphicon-user',
'content' => $this->render('details_step0',[
'form' => $form
]),
'buttons' => [
'next' => [
'title' => Yii::t('app','Next'),
],
],
],
...
],
];
Observing the resulting wizard the values set for 'icon' => 'glyphicon glyphicon-user'generate an HTML tag <span class='glyphicon glyphicon-user'></span>
Is there any way I can modify the icon to be an image i have stored in my web/images folder?
thanks for any suggestions
How do I configure or customize my Menu where in, for example, if I am an admin user, I can see everything on my navigation bar, like, in my case, the Users (list of Users where I can create, update, or delete one), Stores (just like Users, this is where I can configure a specific store), Transactions and then the Logout button. But when an ordinary user/staff logs in, the only thing he/she will see is the Transactions menu and a Logout button as well.
Please help.
Edit:
Here is my menu rendering code:
<?php
echo Menu::widget([
'options' => ['id' => "nav-mobile", 'class' => 'right side-nav'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
],
],
]);
?>
Each item in items array has visible property. Pass expression returning boolean value there.
'items' => [
// Show users section for administrators only
[
'label' => 'Users',
'url' => ['/users/index'],
'visible' => !Yii::$app->user->isGuest && Yii::$app->user->identity->user_type == User::USER_TYPE_SUPER_ADMIN,
],
],
Yoy can also put this condition in additional model method to avoid repeating, something like isAdmin() in User model.
Official documentation:
$items
I think this function is also usefully here
\Yii::$app->user->can("BackendUsersIndex")
'items' => [
// Show users section for administrators only
[
'label' => 'Users',
'url' => ['/users/index'],
'visible' => \Yii::$app->user->can("BackendUsersIndex"),
],
],
I have been trying to get familiar with octobercms, but I've come across an issue I can't seem to resolve. I have a backend controller setup with views etc. Everything works, except that the sidebar isn't loading. Also the tab isn't getting the active state.
http://gyazo.com/25e019c1db34d5807c05ebb4b3277ac7
It should look something like this:
http://gyazo.com/c71a1e1dec7c1e6b81136b313b32da47
Here is a gist with my code: https://gist.github.com/muuknl/fedb8434219c7dbe5d04
If I forgot to give certain information, please let me know and thanks in advance for the help.
here is simple solution
in controller you need to write
BackendMenu::setContext('Archetypics.Team', 'website', 'team');
refer this https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context
BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code');
you need to write same thing what you have written in plugin.php in registerNavigation() function
public function registerNavigation()
{
return [
// menu code
'website' => [
'label' => 'Website',
'url' => Backend::url('muukrls/archetypics/team'),
'icon' => 'icon-pencil',
'permissions' => ['archetypics.*'],
'order' => 500,
'sideMenu' => [
'home' => [
'label' => 'Homepage',
'icon' => 'icon-copy',
'url' => Backend::url('muukrls/archetypics/home'),
'permissions' => ['archetypics.home_access'],
],
'about' => [
'label' => 'About Page',
'icon' => 'icon-list-ul',
'url' => Backend::url('muukrls/archetypics/about'),
'permissions' => ['archetypics.about_access'],
],
// sub menu code
'team' => [
'label' => 'Team Members',
'icon' => 'icon-users',
'url' => Backend::url('muukrls/archetypics/team'),
'permissions' => ['archetypics.team_access']
]
]
]
];
}