How to add a new page to Joomla Admin panel

半腔热情 提交于 2019-12-14 03:13:49

问题


I'm new to Joomla. I need to add a new custom PHP page inside Joomla admin panel (not on the main site) to display some data from my own tables. My Joomla version is 3.4.1 Stable.

Please help me.

Thank you.


回答1:


You might be able to inject a single page to display the data - but I think more than likely your best bet (to do it properly without hacking stuff) might be to develop a small component to handle it best.

By creating the admin component you can create the page you want and display your data however you decide.

If memory serves me correctly, you can create a folder (say com_mycomponent) and create 'mycomponent.php' in that directory. Then you add your php code to that page to do whatever you want. Of course, this is for the most basic - barebones idea.

I will expand because to the best of my understanding we will need an installer to actually 'install' the component (although it's been a while since I've developed heavily in Joomla). If you don't create the installer I think it will cause errors within the system.

  • Create your directory

  • Create one or two directories in the directory

    • admin (required)
    • site (optional)
  • Create 'mycomponent.php' in the admin directory (and site directory if you created one) and write your desired code into the admin file (and/or) site file.

  • Create 'mycomponent.xml' file in com_mycomponent

  • Open 'mycomponent.xml' file and paste the below code

    <?xml version="1.0" encoding="utf-8"?>
    <extension type="component" version="3.4.0">
    <name>Your Name</name>
    <creationDate>2015-05-13</creationDate>
    <author>You</author>
    <authorEmail>you@example.com</authorEmail>
    <description>My Joomla Component</description>
    <files folder="site">
    <filename>mycomponent.php</filename>
    </files>
    
    <administration>
    <menu>MyComponent</menu>
    <files folder="admin">
    <filename>mycomponent.php</filename>
    </files>
    </administration>
    </extension>
    
  • You can remove the following if you did not create the 'site' directory:

    <files folder="site">
    <filename>mycomponent.php</filename>
    </files>
    
  • Zip All the contents under com_mycomponent lets name it com_mycomponent.zip

  • Login to your joomla admin and install com_mycomponent (the same way you would any extension you download)

After it installs, you can view your page at http://yoursite.com/administrator/index.php?option=com_mycomponent




回答2:


What I usually do is create an admin module to display the data. It's a bit quick and dirty but it works. Also there are some extensions in the JED that will let you display data from any table.



来源:https://stackoverflow.com/questions/30215648/how-to-add-a-new-page-to-joomla-admin-panel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!