We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2762
    • 1,198 Posts
    Hi all

    Is there a (php) way to output (with a plugin) the "current" plugin id?
      Free MODx Graphic resources and Templates www.tattoocms.it
      -----------------------------------------------------

      MODx IT  www.modx.it
      -----------------------------------------------------

      bubuna.com - Web & Multimedia Design
      • 40706
      • 128 Posts
      Within an Plugin you could access the current plugin ID with this:

       intval(basename(__FILE__)) 


        • 2762
        • 1,198 Posts
        Thank you very much.
        Tried, probably in the wrong way (inside a variable $pluginid),but does not work: always output "0" (zero)
        $pluginid = intval(basename(__FILE__));


        I also tried

        $pluginid = intval($_GET['id']);


        still "0" [ed. note: banzai last edited this post 11 years, 6 months ago.]
          Free MODx Graphic resources and Templates www.tattoocms.it
          -----------------------------------------------------

          MODx IT  www.modx.it
          -----------------------------------------------------

          bubuna.com - Web & Multimedia Design
          • 40706
          • 128 Posts
          Hmm this way only applies inside a plugincode directly, without an static File. Just usinig the cache filename as id.
          $this->get('id'); should also work. But i don`t understand where you are using this id
            • 2762
            • 1,198 Posts
            Ok i will explain what I'm trying to do smiley

            The path to edit a Evo plugin is something like

            manager/index.php?id=103&a=102


            Where 103 is the plugin id

            So i want to convert it in something like

            manager/index.php?id='.$pluginid.'&a=102


            To add a link to edit my EvoDashboard widgets:



            This is the code of my "test Widget"

            
            /**
             * WelcomeTestWidget
             *
             * Events: OnManagerWelcomePrerender,OnManagerWelcomeHome,OnManagerWelcomeRender
             *
             * Configuration: &WidgetEvoEvent= Widget Box placement:;list;OnManagerWelcomePrerender,OnManagerWelcomeHome,OnManagerWelcomeRender;OnManagerWelcomePrerender &WidgetBoxSize= Widget size:;list;dashboard-block-full,dashboard-block-half;dashboard-block-half &WidgetTitle= Widget Title:;string;Test Widget &WidgetChunk= Widget Chunk:;string;WidgetChunkName 
            ****
            */
            // Run the main code
            
            //blocks
            $WidgetOutput = isset($WidgetOutput) ? $WidgetOutput : '';
            //events
            $WidgetEvoEvent = isset($WidgetEvoEvent) ? $WidgetEvoEvent : 'OnManagerWelcomePreRender';
            // box size
            $WidgetBoxSize = isset($WidgetBoxSize) ? $WidgetBoxSize : 'dashboard-block-full';
            //widget grid size
            if ($WidgetBoxSize == 'dashboard-block-full') {
            $WidgetBoxWidth = 'col-sm-12';
            } else {
            $WidgetBoxWidth = 'col-sm-6';
            };
            //Get plugin id
            $pluginid = intval(basename(__FILE__));
            
            /*Evo Event */
            $output = "";
            $e = &$modx->Event;
            if($e->name == ''.$WidgetEvoEvent.'') {
            /*Widget Output */
            	$WidgetOutput = '<div class="'.$WidgetBoxWidth.'"><div class="widget-wrapper"> <div class="widget-title sectionHeader"><i class="fa fa-globe"></i> '.$WidgetTitle.' <a href="index.php?id='.$pluginid.'&a=102"><i class="fa fa-pencil-square"></i>
            </a></div>
            <div class="widget-stage sectionBody"> bla bla bla </div></div></div>';
            }
            //end Widget
            $output = $WidgetOutput;
            $e->output($output);
            return;
            ?>
            
            
            
              Free MODx Graphic resources and Templates www.tattoocms.it
              -----------------------------------------------------

              MODx IT  www.modx.it
              -----------------------------------------------------

              bubuna.com - Web & Multimedia Design
              • 40706
              • 128 Posts
              I`m very sorry, i didn`t realize that this was under Evo Development. I will have a look at one of our old systems later.