Topic Closed

Hi,

I woud like to rise some pages (some classes of my addon) to the first level of the admin menu. Is it possible?

Thank you

11 months ago#11153

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects
It's only possible using JavaScript.
Which one do you mean? The admin top bar or the floating panel?
11 months ago#11155

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

Sample how to add a first link to the admin top bar, via GetHead hook:

public static function GetHead(){

  global $page;

  if( \gp\tool::LoggedIn() && $page->title ){ // FYI: $page->title means we're not on an admin page

    $item_link =               '/My_Item_Link';
    $item_label =              'My Item Label';
    $item_title =              'My Item Title';
    $item_fa_icon_class_name = 'fa-flag';
    $item_class_name =         'my-item-class-name';

    $page->jQueryCode .= '$("'
    . '<li '
    .   'class=\"' . $item_class_name . '\" '
    .   'title=\"' . $item_title . '\">'
    .     '<a href=\"' . $item_link . '\">'
    .       '<i class=\"fa ' . $item_fa_icon_class_name . '\"></i> '
    .       $item_label 
    .     '</a>'
    . '</li>'
    . '")'
    . '.prependTo("#admincontent_panel > ul:not(.panel_tabs)");';
  }

}

Edited: 11 months ago#11156

Hi, Jurgen. Thankyou for your answer.

Precisely, I hould like to rise some admin pages in the menu. I presume that it is better to do this in the ploating panel...

Framing, I'm making a IOT to mesure temperature and do some alarmistics via mail and produce reports. This device is going to be sent to other continent (Africa). It must be plug and play. If it does not work properly, I have to take a plane and go there. But I don´t like. So the device (banana pi) has linux with a web server with typesetter. There will be a web user that can do some adjusts (change the net configuration, create other users, configure the reports), but not to administrate the web server. To do so (it allready does), he logs on and has to navigate in the floating panel and, for a common user, it is not kind. So, I would like to rise those admin pages in the menu.

Thank you,

Regards,

Alcides Santos

11 months ago#11157

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

Ok. Try sth. like this:

public static function GetHead(){

  global $page;

  if( \gp\tool::LoggedIn() && $page->title ){

    $item_link =               '/My_Item_Link';
    $item_label =              'My Item Label';
    $item_title =              'My Item Title';
    $item_fa_icon_class_name = 'fa-flag';
    $item_class_name =         'my-item-class-name';

    $page->jQueryCode .= '$("<div '
      . 'class=\"panelgroup ' . $item_class_name . '\" '
      . 'title=\"' . $item_title . '\">'
      .   '<a class=\"toplink\" href=\"' . $item_link . '\">'
      .     '<i class=\"fa ' . $item_fa_icon_class_name . '\"></i>'
      .     '<span>' . $item_label . '</span>'
      .   '</a>'
      . '</div>")'
      . '.insertAfter("div#simplepanel > div > div.toolbar")';
  }

}

 

edit: 'insertAfter' instead of 'after'

Edited: 11 months ago#11159

Thank you, Jurgen!

Please excuse me but... where do have to I put this code? In http://www.typesettercms.com/Docs/Plugins/Hooks, there are some links to gpEasy site that don't work...

Regrads,

Alcides Santos

11 months ago#11161

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

where do have to I put this code?

Are your custom IOT admin pages coded as a Typesetter plugin? If so, you could use the GetHead() plugin hook.
It differs a bit whether the plugin class is instantiated or called statically - both will work.
How does your Addon.ini look like?


But you can also simply add the code to the very top of your template.php, without using a plugin hook. Will also work:

<?php

  global $page;

  if( \gp\tool::LoggedIn() && $page->title ){

    $item_link =               '/My_Item_Link';
    $item_label =              'My Item Label';
    $item_title =              'My Item Title';
    $item_fa_icon_class_name = 'fa-flag';
    $item_class_name =         'my-item-class-name';

    $page->jQueryCode .= '$("<div '
      . 'class=\"panelgroup ' . $item_class_name . '\" '
      . 'title=\"' . $item_title . '\">'
      .   '<a class=\"toplink\" href=\"' . $item_link . '\">'
      .     '<i class=\"fa ' . $item_fa_icon_class_name . '\"></i>'
      .     '<span>' . $item_label . '</span>'
      .   '</a>'
      . '</div>")'
      . '.insertAfter("div#simplepanel > div > div.toolbar")';
  }

?><DOCTYPE html>[ ... rest of template.php ]

 

 

 

 

 

11 months ago#11162

It works! I put in Template.php. Thank You!

Any way, you asked: How does your Addon.ini look like?

 

Addon_Name        = 'nbcDevice'
Addon_Unique_ID        = 10
Addon_Version        = 0.18.032
min_gpeasy_version    = 1

; may contain some html: <div>,<p>,<a>,<b>,<br/>,<span>,<tt>,<em>,<i>,<b>,<sup>,<sub>,<strong>,<u>
About = 'Interface com o nbcDevice.';

; Admin links
[Admin_Link:nbcDeviceDefinicoes]
label    = 'Definições'
script    = 'definicoes.php'
class    = '\Addon\nbcDevice\Definicoes'

[Admin_Link:nbcDeviceRede]
label   = 'Rede'
script  = 'rede.php'
class   = '\Addon\nbcDevice\Rede'

[Admin_Link:nbcDeviceUsers]
label   = 'Utilizadores'
script  = 'users.php'
class   = '\Addon\nbcDevice\nbcDeviceUsers'

[Admin_Link:nbcDeviceRelatorioPessoal]
label   = 'Relatório Pessoal'
script  = 'relatorioPessoal.php'
class   = '\Addon\nbcDevice\relatorioPessoal'

[Special_Link:nbcDeviceGrafico]
label   = 'Gráfico'
script  = 'grafico.php'
class   = '\Addon\nbcDevice\Grafico'

[Special_Link:nbcDeviceListagem]
label   = 'Registo'
script  = 'listagem.php'
class   = '\Addon\nbcDevice\Listagem'

[Special_Link:nbcDeviceAlarmes]
label   = 'Alarmes'
script  = 'alarmes.php'
class   = '\Addon\nbcDevice\Alarmes'

[Special_Link:nbcDeviceDashboard]
label   = 'Dashboard'
script  = 'dashboard.php'
class   = '\Addon\nbcDevice\Dashboard'

[Special_Link:nbcDeviceExportar]
label   = 'Exportar'
script  = 'exportar.php'
class   = '\Addon\nbcDevice\Exportar'

[Special_Link:nbcDeviceGeraXML]
label   = 'GeraXML';
script  = 'gera_xml.php'
class   = '\Addon\nbcDevice\GeraXML'

[GetHead]
script = jscript.php
method = plugin_function
Edited: 11 months ago#11163

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

[GetHead]
script = jscript.php
method = plugin_function

Should have worked.
You probably just didn't click 'Upgrade' in Plugins->Manage->nbcDevice->Options, which is required after Addon.ini changed / hooks were added (?)

11 months ago#11164

Hi Jurgen, thank you very much for your concern.

Several issues:

 

1.

It works for one. That's fine. But how to do for two? I tried to put on top of my template.php

<?php

global $page;

if( \gp\tool::LoggedIn() && $page->title ){

    $item_link =               '/index.php/Admin_nbcDeviceRede';
    $item_label =              'Rede';
    $item_title =              'Rede';
    $item_fa_icon_class_name = 'fa-flag';
    $item_class_name =         '\Addon\nbcDevice\Rede';

    $page->jQueryCode .= '$("<div '
     . 'class=\"panelgroup ' . $item_class_name . '\" '
     . 'title=\"' . $item_title . '\">'
     .   '<a class=\"toplink\" href=\"' . $item_link . '\">'
     .     '<i class=\"fa ' . $item_fa_icon_class_name . '\"></i>'
     .     '<span>' . $item_label . '</span>'
     .   '</a>'
     . '</div>")'
     . '.insertAfter("div#simplepanel > div > div.toolbar")';

    $item_link2 =               '/index.php/Admin_nbcDeviceUsers';
    $item_label2 =              'Utilizadores';
    $item_title2 =              'Utilizadores';
    $item_fa_icon_class_name2 = 'fa-flag';
    $item_class_name2 =         '\Addon\nbcDevice\nbcDeviceUsers';

    $page->jQueryCode .= '$("<div '
     . 'class=\"panelgroup ' . $item_class_name2 . '\" '
     . 'title=\"' . $item_title2 . '\">'
     .   '<a class=\"toplink\" href=\"' . $item_link2 . '\">'
     .     '<i class=\"fa ' . $item_fa_icon_class_name2 . '\"></i>'
     .     '<span>' . $item_label2 . '</span>'
     .   '</a>'
     . '</div>")'
     . '.insertAfter("div#simplepanel > div > div.toolbar")';     
     
}

but neither one appears. In the chrome's inspector I get the error "Uncaught SyntaxError: Unexpected identifier" pointing to the line where that code appears in the source. I tried to put in the second part' last line «. '.insertAfter("div#simplepanel > div > div.panelgroup ' . $item_class_name . '\" )'; » but the some error message appears.

 

2.

 In my  jscript.php I have other code:

<?php
function plugin_function($js_files){
    global $addonRelativeCode,$page;
    $page->head_js[] = $addonRelativeCode.'/javascript.js';
}

This code is not related.

 

3. 

Any awy, if I add the code for one page at the end of jscript.php I get the errar "Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /var/www/html/addons/nbcDevice/jscript.php on line 7" (line 7 is where the addad code begins)

 

4. If I add to Addon.ini

[GetHead]
script = jscript2.php
method = plugin_function

and in jscript2.php i put the some code, identical error message  "Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /var/www/html/addons/nbcDevice/jscript2.php on line 3"

 

Can you please give some hint?

Thank you very much.

 

Best regards,

Alcides Santos

11 months ago#11165

Jurgen, you asked:

You probably just didn't click 'Upgrade' in Plugins->Manage->nbcDevice->Options, which is required after Addon.ini changed / hooks were added 

Yes, I follow this procedure.

Thank you, Jurgen

11 months ago#11166

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

First thing I see:

$item_class_name was meant to be used for possible CSS class(es), e.g. for custom backgroubd colors or alike.



But if you're going to add several links, we'd be better off with a different approach. Give me a few minutes…
 

11 months ago#11167

Ok, Jurgen. Thanks a lot. Meanwhile, I'm going to play with the information that $item_class_name is to be used with css.
11 months ago#11168

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects

I just made a small separate plugin, solely to add links to the admin panel. Might come in handy

get it from here AddAdminLinks_1_0.zip

Links are defined in $links array in Addon.php

edit: every panelgroup has 2 css classes: add-admin-link add-admin-linkN (where N is 0 to total number of links in reverse order)
I only defined the common .add-admin-link to have a dark blue-grey background. If you want to use different colors, just add sth. like
.add-admin-link0 { background:#543; }
.add-admin-link1 { background:#453; }
and so on, to Addon.css

Edited: 11 months ago#11169

Uau! I don´t know how to thank you! I'm going to put it my device right now!
11 months ago#11170

JURGEN!!!!

You even tried to find out what various words mean in Portuguese to put the appropriate icon!

It's really fantastic!

Thank you so much!

11 months ago#11171

... and thank you for the icons...
11 months ago#11172

juergen
1.4K Posts
51.3K Downloads
16 Plugins
design, web development & visual effects
Sure thing. Glad you like it.
11 months ago#11173

Topic Closed

 

News

Typesetter 5.1
8/12/2017

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register