📜 ⬆️ ⬇️

Creation of modules for PHPShop.CMS Free - Tips (Part 2)

I continue to publish useful tips for web developers using PHPShop.CMS Free as site builder. In this article we will analyze the finer points of GUI interfaces and work with the debug panel.

GUI interfaces

PHPShop framework and subtle points in its use.

Purpose of the primary form loader

Often, developers to create administrative part interfaces create files by copying existing ones and do not understand why, by specifying a copied piece of code from the adm_news_new.php file as control actions, they cannot display a simple form of module parameters.

//     $PHPShopGUI->setAction($_GET['id'],'actionStart','none'); //   $PHPShopGUI->getAction(); 

The trick is that the $ PHPShopGUI-> setAction method ($ _ GET ['id'], 'actionStart', 'none') is used if the $ _GET ['id'] parameter is passed to the form when loading. If there are no parameters in the form, the setLoader () method of the form is used:
')
 //     $PHPShopGUI->setLoader($_POST['editID'],'actionStart'); //   $PHPShopGUI->getAction(); 


setLoader () has as its first argument $ _POST ['editID'], which serves as a dependency marker, that the actionStart function specified by the second argument will be executed provided that $ _POST ['editID'] is not defined.

And if $ _POST ['editID'] is specified, it will execute the actionInsert () function, which should be in the same file. The actionInsert action is declared in the actionStart () function by including a string in the form:

 $ContentFooter=$PHPShopGUI->setInput("submit","editID","","right",70,"","but","actionInsert"); $PHPShopGUI->setFooter($ContentFooter); 

This insert will graphically display the OK button, when clicked, the actionInsert () function will be executed.

Debugging

For debugging, the PHPShopDebug debug pane is used , where useful information is displayed.

Capturing navigation data


image

To understand what data is responsible for what and how you can use it there is a Request menu in the debug panel. By clicking on it and revealing the full output, we get useful data and variable names to use, for example:

 GLOBALS['SysValue']['nav']: Array ( [truepath] => /price/ [path] => price [nav] => [name] => [id] => [page] => [querystring] => debug=request [query] => Array ( [debug] => request ) [longname] => /price/ [url] => /price/ ) 

For example, the variable $ GLOBALS ['SysValue'] ['nav'] [path] contains the address of the section price, etc.

To enable the debug panel, set the parameter [my] debug = “true”; in the config.ini configuration file

Hiding Notice (debug notifications)

Often, local servers and hosting companies indulge in the option to display all debugging messages for php. This is very inconvenient, and newbies are hit by a number of errors, but these are not errors, but debug messages for developers. To a mere mortal, they are like a goat's fifth leg. You can of course even remove all the errors in the .htaccess file, but then debugging will be difficult.

To solve this problem, there is an Error Log module that allows you to manage php errors and assign your own handlers for them. All errors are written to the module database and are available for analysis. To record certain events in the module database, use the record:

 trigger_error(" ", E_USER_NOTICE); 

Error Log is included with PHPShop.CMS Free. The optimal setting for the error output level in the module is to block the output of all errors, while all errors and debugs will be written to your database and not scare normal users of the site.

In the next part, let's analyze the creation of a new module from the interface of the PHPShop IDE integrated development environment using the example of the Example module.

PS Thank you for your attention; from the experience of the last lesson it turned out that many did not like part 1 . If there are questions and misunderstandings of information, then please express them in the comments. If you have nothing to ask, you shouldn't just minus it, get busy, do not spoil your “living karma”.

Source: https://habr.com/ru/post/129157/


All Articles