I have a module where I need to:
Manage Models
Manage Module Settings
API Authentication
Look & Feel
Etc
For Manage Models I obviously have a ModelAdmin extension
And for the latter Manage Module Settings I've had to create a DataExtension
Though this splits up the "Module Functionality" into two sections, ModelAdmin gets its own menu item on the sidebar, but the DataExtension only adds tabs to the Settings menu item.
I've searched around but to no avail on how to consolidate my custom tabs within the same menu item that ModelAdmin creates.
Is this possible? I understand the semantics behind ModelAdmin being that it only Administers Models but surely the functionality exists where you can add tabs to the menu item it creates that aren't models?
Surely it's not an abnormal scenario
The only way you could do this would be to extend LeftAndMain (as you have mentioned).
This can be a little daunting, but LeftAndMain is basically just a container for 3 templates:
Main admin template
Left hand nav template
Main edit form
At a basic level you can just create an extension to LeftAndMain, then add a custom "EditForm" function that has the settings fields you need (as well as actions to save the data).
Then if you want it to look fancier then you can overwrite the default LeftAndMain templates in framework/admin/tempaltes.
There are some docs on this on the Silverstripe site: https://docs.silverstripe.org/en/3.4/developer_guides/customising_the_admin_interface/cms_layout/
Hope that helps a bit.
Related
I need to incorporate News and Announcements in my silverstripe website, both news and announcements have the exact same structure and they both use https://github.com/nyeholt/silverstripe-news. in the html template I have two sections one for the news and another for the announcements.
what is the proper way to implement this:
should I just copy and past the /news module folder and use one for the news and the other for announcements.
or add another db field as flag to specify if this is a news article or an announcement article, but then in the cms the user would have to check this every time.
or is there anything else, I don't know
Duplicating the folder would not have the result you expect unless youd rename all the classes in side of the new one.
Basically the folder is just a place for the classes to be, not something that you access when you actually request an news article, you use SilverStripes routes for that.
Static assets would be something that are be loaded from a module folder.
The best way to add a new behaviour to an extension is to use a DataExtension.
See https://docs.silverstripe.org/en/3.4/developer_guides/extending/extensions/
Other way would be if the module uses sitetree for placing the "news holder". Then you have the option also to just create two holders with different names and then if you want to show a list of a paricular parent just filter with the parentId that relates to the correct holder.
Third option would be to just would to add a new class under mysite that extends the modules classes and override only SOME of the methods to suite your needs.
I'm working in OpenCart 1.5.5 on some sort of newsmodule for in the side bar. I've got it all running in the back-end, but i don't know how i could asign this module module/aselsi to the right side bar on the home page, product page and category page.
I've already looked in some source code's, but i don't fully understand how this particilur thing works.
I did try to make it work by inserting in the DB tabels oc_layout and oc_layout_route some info, but that also didn't work.
So my question is: How can i make my extension / module apear on the front-page?
By running in the back-end I guess You have created a custom controller, model and view for some form where You manage Your news. That is OK.
But since this should be a module You also have to create a backend part for this module so that it could be installed and assigned to the layout on certain pages. The simplest way how to do this is to copy these files:
admin/controller/module/banner.php
admin/language/<YOUR_LANGUAGE>/module/banner.php
admin/view/template/module/banner.php
into Your new
admin/controller/module/aselsi.php
admin/language/<YOUR_LANGUAGE>/module/aselsi.php
admin/view/template/module/aselsi.php
and rename all the class names, constants, model and language file names from banner to aselsi. After this You should see a new Aselsi module under Extensions > Modules in You administration where You should be able to assign this module to pages and positions...
Just want to mention that simple copy-paste + rename is not enough, You would have to edit some other parts as well to get it working.
EDIT: I'm not at the code right now, but yes, You are right, it has a lot to do with that line You are mentioning in comment. Each module setting is saved as serialized string (which is a serialized array) which contains module settings - layout, position, sort_order, etc. The key is the module key - aselsi in Your case, same as all other modules has their own modules. By only installing the module You set the module as active but You can show the module by saving it's settings. In frontend controllers for left, right column and top and bottom content the active modules are then populated and all set to display on that layout and on that position are displayed then.
The installing/uninstalling of module (in backend) can be extended to e.g. add/remove new DB tables for that module and/or for altering current DB tables (by adding new columns, etc.) by implementing install and uninstall methods with their respective logic.
I hope this simple explanation helps a little.
I have created an admin module that replicates the CMS->Page grid layout. I have copied the core code from adminhtml\default\default\template\widget\grid.phtml to my admin page template file and made my block for that template extend Mage_Adminhtml_Block_Widget_Grid.
The CMS pages display fine and I have also managed to add my own column to the grid, however none of the default columns (or my own) are sortable or filterable.
Does anyone know what might be going on here? Have I made an error somewhere or would I manually need to make these default fields sortable?
A good place to start would be this class, used for the product grid:
Mage_Adminhtml_Block_Catalog_Product_Grid
In particular the functions
_prepareCollection()
and
_prepareColumns()
I've used that block as the basis for my own custom grids. If you need any further pointers feel free to let me know and I'll do my best to take a look
I ha created a new magento module. It shows info like for example Sales/Orders grid, then on click of order there is edit(in original magento view) tabs. I have created some tabs and I want one of them to be grid, like in orders shipment, creditmemos or invoices.
How do I do that?
It's not really too much different then adding a grid to any other page. I know when I was building a module I dug into the Google Base addon that is native to Magento, I found a lot of good code there to help me understand how to implement different aspects of an admin module.
For instance my tab block overides grid, like so:
class Ssi_Crm_Block_Quotes_Edit_Tab_Bom_Product extends Mage_Adminhtml_Block_Widget_Grid
This class then overrides the standard grid functions such as _prepareCollection() and _prepareColumns() stuff that you can find documented elsewhere.
When you log into the Magento Admin Panel, you're only shown menu items that your role allows you to. Where in the Core does Magento check the user's role to determine which Navigation items should be shown? (I'm not interested in the _isAllowed method on Admin controllers, I'm interested in the Navigation rendering).
Also, as along as I'm here, outside of the aforementioned _isAllowed, navigation rendering, and SOAP/RPC API methods, what other parts of the Magento system rely on ACL?
Looks like Mage_Api_Model_Config and Mage_Admin_Model_Config are involved in the API and admin permissions respecively, they both have the methods
loadAclResources()
getAclAssert()
getAclPrivilegeSet()
Cheers,
JD
Found what I was looking for, but I'm still interested in other areas of the admin that use ACL resources.
Mage_Adminhtml_Block_Page_Menu::_checkAcl