add custom module under a menu stream - php

I am creating my own module and one of its requirement is to have it located in a certain menu. My problem is that the menu is generated using a plugin PyroStreams.
So first things first, I downloaded a copy of the sample module on the Github, then have it place in addons/default/modules/. I refreshed my PyroCMS Admin -> Add-ons -> Modules and see the sample module in there. As stated on the detail.php of this sample module
public function info()
{
return array(
'name' => array(
'en' => 'Test Modules'
),
'description' => array(
'en' => 'My custom module.'
),
'frontend' => FALSE,
'backend' => TRUE,
'menu' => 'content', // You can also place modules in their top level menu. For example try: 'menu' => 'Sample',
'sections' => array(
'items' => array(
'name' => 'Test', // These are translated from your language file
'uri' => 'admin/sample',
'shortcuts' => array(
'create' => array(
'name' => 'sample:create',
'uri' => 'admin/sample/create',
'class' => 'add'
)
)
)
)
);
}
It should appear on the Content menu which is correct. Now, I can't find anything on docs that states instructions on properly mapping the menu for custom modules, so out of initiative I tried to change the value for menu => "content" to menu => "Test Stream" but that didn't work. As shown in the screenshot below, that is where I wanted to place my custom module, under the menu "Test Stream". What am I missing?

Add this method to your detail.php file:
public function admin_menu(&$menu)
{
// Create main menu item
add_admin_menu_place('lang:module:title', 9); // 9 is the placement order of your menu item, it would be after profile
// Create sub-menu
$menu['lang:module:title']['lang:module:submeu1'] = 'admin/add';
$menu['lang:module:title']['lang:module:submeu2'] = 'admin/edit';
}
also set the 'menu'=> false, at your info() method.

Related

Prestashop 1.6 add tinymce field to admin preferences

I'm trying to add a new field to Admin Preferences - a textarea field with tinymce. I've added code to AdminPreferencesController.php:
$this->fields_options['contact'] = array(
'title' => $this->l('Contact'),
'icon' => 'icon-cogs',
'submit' => array('title' => $this->l('Save')),
);
$this->fields_options['contact']['fields']['PS_CONTACT_ADDITIONAL_INFO'] = array(
'type' => 'textarea',
'label' => $this->l('Short description'),
'name' => 'short_description',
'lang' => true,
'cols' => 60,
'rows' => 10,
'autoload_rte' => 'rte',
'col' => 6,
);
But tinymce doesnt' appear and when I'm using HTML tags after saving they disappear. Presta strips all HTML tags.
How to allow HTML tags on this field and enable tinymce?
It seems that you can't just add it in a regular way. But you can implement it in a next way.
First of all, use field type textareaLang instead of textarea and add a parameter 'validation' => 'isCleanHtml' to this field
$this->fields_options['contact']['fields']['PS_CONTACT_ADDITIONAL_INFO'] = array(
'type' => 'textareaLang',
'label' => $this->l('Short description'),
'name' => 'short_description',
'lang' => true,
'cols' => 60,
'rows' => 10,
'col' => 6,
'validation' => 'isCleanHtml'
);
Create your own script to initialize your editor. I created a script tinymce.init.js and put it to js/admin/ folder
$(document).ready(function(){
ad = ''; // this is defenition of the external plugin path. I didn't fint how it can impact on script if it's empty but by default it it the path to your admin folder
iso = iso_user;
var config = {
selector: '.textarea-autosize'
};
tinySetup(config);
});
Then include tinymce script and your own to this controller AdminPreferencesController.php
public function setMedia()
{
$this->context->controller->addJquery();
$this->context->controller->addJS(
array(
_PS_JS_DIR_.'admin/tinymce.init.js',
_PS_JS_DIR_.'tiny_mce/tiny_mce.js',
_PS_JS_DIR_.'admin/tinymce.inc.js'
)
);
parent::setMedia();
}
It should implement your requirements. But don't forget that now you should call your configuration field in multilingual scope. So, add a language id to Configuration::get() like
Configuration::get('PS_CONTACT_ADDITIONAL_INFO, $id_lang)
whenever you use it.
P.S. Bear in mind that the best solution for your goal is to create a simple module which will handle this. And far more, it is recommended way.

ZF2 Navigation Order

I have following problem and i tested it with data from the original documentation of the zend framework 2. I dont know if i miss something or if it is just a missing functionality.
In the following example i create a navigation with two levels and then print the navigation labels with echo. As you can see i set an order for both first level pages and for two second level pages. If you look at my output you can see that only the first level pages are in right order. The second level pages arent in right order.
For every level you put in a navigation greater than level one, the order isnt changed.
Anybody of you have the same problem or can tell me what iam doing wrong? Or is this a not given functionality of the zend-navigation module?
Thanks
Script
$container = new \Zend\Navigation\Navigation(
array(
array(
'label' => 'ACL page 1 (guest)',
'uri' => '#acl-guest',
'resource' => 'nav-guest',
'order' => 777,
'pages' => array(
array(
'label' => 'ACL page 1.1 (foo)',
'uri' => '#acl-foo',
'resource' => 'nav-foo',
'order' => 666
),
array(
'label' => 'ACL page 1.2 (bar)',
'uri' => '#acl-bar',
'resource' => 'nav-bar',
),
array(
'label' => 'ACL page 1.3 (baz)',
'uri' => '#acl-baz',
'resource' => 'nav-baz',
),
array(
'label' => 'ACL page 1.4 (bat)',
'uri' => '#acl-bat',
'resource' => 'nav-bat',
'order' => 111
),
),
),
array(
'label' => 'ACL page 2 (member)',
'uri' => '#acl-member',
'resource' => 'nav-member',
'order' => 555
)
)
);
foreach ($container as $page) {
echo $page->label."<br>";
if ($page->hasPages()) {
foreach ($page->getPages() as $page2) {
echo $page2->label."<br>";
}
}
}
die("ASD");
Output
ACL page 2 (member)
ACL page 1 (guest)
ACL page 1.1 (foo)
ACL page 1.2 (bar)
ACL page 1.3 (baz)
ACL page 1.4 (bat)
ASD
Method $page->getPages() return Array (docs). Elements are ordered only if list is Navigation object.
Try:
foreach ($container as $page) {
echo $page->label."<br>";
if ($page->hasPages()) {
$subpages = new \Zend\Navigation\Navigation($page->getPages());
foreach ($subpages as $page2) {
echo $page2->label."<br>";
}
}
}

Drupal 7 Node Content Type Template Path

I am working on a module for Drupal 7. I have a template defined for my content type as node--[content type].tpl.php and placed it in the "themes/[selected theme]/template" directory. I want to keep this template in my "module" directory instead. So when the module is installed I don't have to place the file in to the selected theme folder every time. Is there a way to do this?
Thank you all in advance.
I have less than 10 rep so I cant answer my own question so I'll just modify the question
The following is working for me some how. For both case node edit form view and node view
function [content type]_theme() {
return array(
'[content type]_node_form' => array(
'arguments' => array(
'form' => NULL,
),
'template' => 'node--[content type]--edit',
'render element' => 'form',
),
'node__[content type]' => array (
'variables' => array(),
'template' => 'node--[content type]' ,
'base hook' => 'node',
'path' => "sites/all/modules/[content type]_update/[content type]_update/[content type]/",
),
);
}
I don't completely understand this but it's working.
This link should get you going:
http://www.wdtutorials.com/2011/06/13/drupal-7-how-create-custom-theme#.U6sZ741dXag
You basically want to create a new custom theme.
In addition to the above tutorial, create a new folder 'templates' and add your .tpl files in there instead of the core themes folder.
You can use the below format to specify the template path. Then you can place the tpl file in your module folder.
function MODULENAME_theme() {
return array(
'yourcustom_theme' => array(
'template' => 'mypage', // template file called mypage.tpl.php
'path' => drupal_get_path('module', 'MODULENAME'),
)
);
}

Change subpanel order in SugarCRM 7

How can one change the order on each subpanel either by code or through the GUI?
In Sugar 6 the user could change the order simply by dragging and dropping the subpanels under each module.
From what I can see this is not possible in 7.x.
I have tried to change
'order' => 1
in
custom/Extension/modules/Opportunities/Ext/Layoutdefs/some_file.php
with no luck at all..
UPDATE:
As UTAlan stated,
this will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590
Until then, here is the reason and the solution:
The 'order' => 1, does not seem to work on Sugar 7 at the moment.
Solution
Copy the file
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
to
custom/modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Now, add your custom subpanel definition to the beginning of the array or in any order you desire.
My example looks like this now:
$viewdefs['Opportunities']['base']['layout']['subpanels'] = array(
'components' => array(
// This is my custom module
array(
'layout' => 'subpanel',
'label' => 'LBL_OPPORTUNITIES_FOOBAR_TITLE',
'context' => array(
'link' => 'opportunities_foobar_1',
),
),
.. // Code ommited
array(
'layout' => 'subpanel',
'label' => 'LBL_EMAILS_SUBPANEL_TITLE',
'context' => array (
'link' => 'archived_emails',
),
),
),
'type' => 'subpanels',
'span' => 12,
);
Long Answer:
Why is 'order' => 1 not working anymore?
Inside include/MetaDataManager/MetaDataConverter.php:327:
public function toLegacySubpanelLayoutDefs(array $layoutDefs, SugarBean $bean) {
..
foreach ($layoutDefs as $order => $def) {
..
$return[$def['context']['link']] = array(
'order' => $order,
..
}
The order that is being rendered in the view is based on which order each bean-name is inserted inside the 'components'-key inside this file:
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Core modules are hard-coded inside the subpanel file for Opportunities.
This will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590

Open a thickbox-style Lightbox from WP Admin Bar

Folks,
I'm currently setting up a WP install. In order for the client to access a custom help-document, I added an additional dropdown menu in the admin-bar as a WP plugin via the following php-file:
<?php
function pub_admin_bar_init() {
if (!is_super_admin() || !is_admin_bar_showing() )
return;
add_action('admin_bar_menu', 'pub_admin_bar_links', 500);
}
add_action('admin_bar_init', 'pub_admin_bar_init');
function pub_admin_bar_links() {
global $wp_admin_bar;
$links = array(
'Chapter 1' => 'http://manual.domain.com/index1.html',
'Chapter 2' => 'http://manual.domain.com/index2.html',
'Chapter 3' => 'http://manual.domain.com/index3.html',
'Chapter 4' => 'http://manual.domain.com/index4.html',
'Chapter ...' => 'http://manual.domain.com/index5.html',
);
$wp_admin_bar->add_menu( array(
'title' => 'Help-Document',
'href' => false,
'id' => 'pub_links',
'href' => false
));
foreach ($links as $label => $url) {
$wp_admin_bar->add_menu( array(
'title' => $label,
'href' => $url,
'parent' => 'pub_links',
'meta' => array('target' => '_blank')
));
}
}
?>
The dropdown works fine and the referenced html-files located in the subdomain of the same domain get called in a new tab.
However, in order to have everything neatly arranged within the WP admin, I'd like to call the menu items in the new admin-bar dropdown via an iframe Lightbox.
I managed to set this up in the Dashboard intro section using the built-in thickbox with the following syntax:
<a style="text-decoration:none;"
href="http://codex.wordpress.org/First_Steps_With_WordPress?
keepThis=true&TB_iframe=true&height=800&width=1200" class="thickbox"
title="sometitle">First Steps with WordPress</a>
This lets me call the html help-files (or any other url for that matter) as an iframe in a thickbox-style overlay.
Now my actual question:
Could someone point me to how I could make the links in the admin-bar dropdown ('Chapter 1' => 'http://manual.domain.com/index1.html', ...) as thickbox-style overlays instead of target=_blank?
Help very much appreciated. Thanks a lot!
'meta' => array('target' => '_blank'),
You forget of ","

Categories