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']
]
]
]
];
}
Related
I have made a custom palette in tt_content.php and want to add it to all content elements on the appearance tab like this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'--palette--;My Palette;my_palette',
'',
'before:sectionIndex'
);
This works for everything except Grid Elements (gridelements_pi1). How do I make the new palette show up on Grid Elements as well?
The comment from #MathiasBrodala lead me to finding the answer is in the order of extensions.
In this case I needed to add gridelements under suggests in my ext_emconf.php which ensures it will be loaded before my site package.
$EM_CONF[$_EXTKEY] = [
'title' => 'My Package',
'description' => 'TYPO3 Sitepackage',
'category' => 'templates',
'version' => '1.0.0',
'state' => 'stable',
'constraints' => [
'depends' => [
'typo3' => '8.7.0-9.5.99',
'fluid_styled_content' => '8.7.0-9.5.99'
],
'suggests' => [
'gridelements' => '9.3.0-0.0.0',
],
'conflicts' => [
],
],
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1
];
Hello :) I'm just learning Wordpress and I can not find an answer to a question about how to write code.
Here is my code:
if ( !function_exists( 'mythemename_social_sites_list' ) ) :
function mythemename_social_sites_list() {
return [
[ 'name' => 'Twitter', 'icon' => 'fab fa-twitter' ],
[ 'name' => 'Facebook', 'icon' => 'fab fa-facebook-f' ],
[ 'name' => 'Google Plus', 'icon' => 'fab fa-google-plus-g' ],
];
}
endif;
In general, the function returns many more elements of the array, but here I gave only 3 to be more visible. What's the problem?
Is there any sense to write it this way? In a sense, a function that returns an array but does nothing with it? From what I understand, functions should be used when they do something. For example, this one would take an array, then do something with it and return the changed one.
Would not it be better to just write this:
global $mythemename_social_sites_list;
$mythemename_social_sites_list = [
[ 'name' => 'Twitter', 'icon' => 'fab fa-twitter' ],
[ 'name' => 'Facebook', 'icon' => 'fab fa-facebook-f' ],
[ 'name' => 'Google Plus', 'icon' => 'fab fa-google-plus-g' ],
];
Global, because I use this array in several places.
Thanks in advance for the brightening :)
I have a plugin that generates a navbar using PHP. The folder is in project/config/menu.php
It looks like this:
<?php
return [
//HORIZONTAL MENU LAYOUT - MENU
'horizontal' => [
[
'title' => 'bar',
'link' => '/bar/all',
'active' => 'bar*',
'icon' => 'fa fa-sign-in',
],
[
'title' => 'foo',
'link' => '/foo/all',
'active' => 'foo*',
'icon' => 'fa fa-sign-out',
],
]
];
I want to add some model information.
This is my attempt:
<?php
use Auth;
$id = Auth::user()->id;
return [
//HORIZONTAL MENU LAYOUT - MENU
'horizontal' => [
[
'title' => 'bar',
'link' => '/bar/'. $id,
'active' => 'bar*',
'icon' => 'fa fa-sign-in',
],
[
'title' => 'foo',
'link' => '/foo/all',
'active' => 'foo*',
'icon' => 'fa fa-sign-out',
],
]
];
I get this error: Class 'Auth' not found. I have also tried with models:
$model = \App\Model::count();
Which gives me this error:
Call to a member function connection() on null
How do I use these models here?
laravel config loads before any other things, so instantiating model will give an error, and that error you are getting is due to no database connection information loaded during this specific config file loads. I wonder why you need to call model in config, you can simply build something like templates of menu layout like below:
<?php
return [
//HORIZONTAL MENU LAYOUT - MENU
horizontal' => [
[
'title' => 'bar',
'link' => '/bar/%d', // here %d is userId from database
'active' => 'bar*',
'icon' => 'fa fa-sign-in',
],
[
'title' => 'foo',
'link' => '/foo/all',
'active' => 'foo*',
'icon' => 'fa fa-sign-out',
],
]
];
and later replace that %d with value from model.
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/
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"),
],
],