Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

How do I create a page in the admin panel??

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-20-2015, 09:17 AM
 
cvaughan02 cvaughan02 is offline
 

Member
  
Join Date: Mar 2014
Location: st. louis, mo
Posts: 22
 

Angry How do I create a page in the admin panel??

Ok, i've been on this for two days. all the docs/walkthroughs are way too specific. I just need to know how to create a page in the admin section.

here's what I've done so far:

created a new controller that extends \XLite\Controller\Admin\AAdmin. It has getTitle and getAllowedTargets and both of those seem to be working as expected.

I have created a LeftMenu item to point to my new controllers target. this also seems to work.

NOW... how do I assign this controller an actual template and action? The ONLY thing I need this to do is export some data (which I can figure out), but first I need to get some type of information besides the title to display on the page. I don't need an itemlist or any other complex model. right now i'm just trying to add some static content to the page.

please help :'( it's been two days!
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS.
Reply With Quote
  #2  
Old 05-20-2015, 09:49 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: How do I create a page in the admin panel??

I feel your pain! Maybe this will help:

Create a file:
XLite/Module/YourDevID/YourModule/Controller/Admin/MyPage.php

with these contents:
Code:
<?php namespace XLite\Module\YourDevID\YourModule\Controller\Admin; /** * My Page controller */ class MyPage extends \XLite\Controller\Admin\AAdmin { /** * Return the current page title (for the content area) * * @return string */ public function getTitle() { return static::t('My Admin Page'); } }

Create another file:
XLite/Module/YourDevID/YourModule/View/MyPage.php

with these contents:
Code:
<?php namespace XLite\Module\YourDevID\YourModule\View; /** * My Page Viewer Class * * @ListChild (list="admin.center", zone="admin") */ class MyPage extends \XLite\View\Dialog { /** * Return list of allowed targets * * @return array */ public static function getAllowedTargets() { $list = parent::getAllowedTargets(); $list[] = 'my_page'; return $list; } /** * Register JS files * * @return array */ public function getJSFiles() { $list = parent::getJSFiles(); $list[] = $this->getDir() . '/custom.js'; return $list; } /** * Register CSS files * * @return array */ public function getCSSFiles() { $list = parent::getCSSFiles(); $list[] = $this->getDir() . '/style.css'; return $list; } /** * Return templates directory name * * @return string */ protected function getDir() { return 'modules/YourDevID/YourModule/my_page'; } }

The above of course assumes you already have a Main.php for your module.


Here is what has confused me in the past, and Tony helped me understand:
Your Controller, must be named the same as your target.

If your target is: some_funky_target

Then your controller must be: SomeFunkyTarget.php
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following 2 users thank totaltec for this useful post:
cvaughan02 (05-21-2015), qualiteam (05-21-2015)
  #3  
Old 05-20-2015, 09:52 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: How do I create a page in the admin panel??

Okay now that we have the proper code established, we need a template.

Create your template:
skins/admin/en/modules/YourDevID/YourModule/my_page/body.tpl

with these contents:
Code:
<h1>Hello World!</h1>

X-Cart automatically looks in the result of getDir() for a template named body.tpl if getDefaultTemplate() is not specified. And it will look in the skin admin directory if this is an admin controller.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
qualiteam (05-21-2015)
  #4  
Old 05-20-2015, 10:07 AM
 
cvaughan02 cvaughan02 is offline
 

Member
  
Join Date: Mar 2014
Location: st. louis, mo
Posts: 22
 

Default Re: How do I create a page in the admin panel??

Quote:
Originally Posted by totaltec
Okay now that we have the proper code established, we need a template.

Create your template:
skins/admin/en/modules/YourDevID/YourModule/my_page/body.tpl

with these contents:
Code:
<h1>Hello World!</h1>

X-Cart automatically looks in the result of getDir() for a template named body.tpl if getDefaultTemplate() is not specified. And it will look in the skin admin directory if this is an admin controller.



OMG thank you! that's what I was missing (and what the docs are missing). I had just about everything correct, except the name of the target and couldn't figure out how to connect them.
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS.
Reply With Quote

The following user thanks cvaughan02 for this useful post:
totaltec (05-20-2015)
  #5  
Old 05-20-2015, 10:15 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: How do I create a page in the admin panel??

You are quite welcome! Glad it worked. It did sound like you were 90% of the way there. I just posted the other info to provide a complete picture for anyone else that needed the solution.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:58 AM.

   

 
X-Cart forums © 2001-2020