1
phillipd
Why isn't smarty used in admin scripts
  • 2004/10/31 4:14

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I just checked all the modules that come with XOOPS and shockingly discovered that none use smarty in their admin scripts. Why is this? One exception to this is agendax (I know it doesn't come with xoops), and it uses very little in the way of smarty and templates in its admin code.

Puzzled

Doug P

2
Dave_L
Re:Why isn't smarty used in admin scripts
  • 2004/10/31 4:46

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


The reason is simply that no one bothered to do it.

You can do it now, but it's awkward. I think that XOOPS 2.1 is supposed to have better support for this.

3
phillipd
Re:Why isn't smarty used in admin scripts
  • 2004/10/31 5:04

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm a beginner at developing XOOPS modules. I've heavily modified the xoopsfaq module to make it do what I needed and have created another GIS module to display maps from a ESRI system from scratch. I was about to write my first admin module for this GIS project when I discovered this lack of smarty usage in admin scripts.

If I could impose on one of you hard working XOOPS masters...

1) Why is it anymore awkward than just writing a module? What am I missing here?

2) What "support" was required that wasn't there previously.

3) Are there any restrictions I should know about?

4) Do you know of any other modules with admin scripts, that use smarty as the prevalent way to generate admin forms, I can use for educating myself?

Gratefully

Doug P

4
dheltzel
Re:Why isn't smarty used in admin scripts
  • 2004/10/31 13:53

  • dheltzel

  • Not too shy to talk

  • Posts: 164

  • Since: 2003/1/8 1


Quote:

phillipd wrote:
1) Why is it anymore awkward than just writing a module? What am I missing here?

2) What "support" was required that wasn't there previously.

3) Are there any restrictions I should know about?

4) Do you know of any other modules with admin scripts, that use smarty as the prevalent way to generate admin forms, I can use for educating myself?

Gratefully

Doug P

1) I don't consider it awkward at all. It's just like using Smarty in other pages, except you might need to adjust the path used to include files. This is pretty easy to debug (error message like "cannot find file X").

2) Maybe he means that more of the system module pages will be using Smarty out of the box. All but the system module will be removed from 2.1 and maintained separately.

3) Nope. Just remember you are in the admin dir one level down.

4) I "borrowed" my first modules code from Agenda-X and then stripped out all the un-needed code, so my modules all use Smarty in the admin pages, but you won't get much more than you would from Agenda-X.

I heartily encourage you to use Smarty everywhere. It works and obviously is easier to maintain. The fact that Smart was not used in the system module might be part of the reason that not much updating has been done there. The code is hard to understand because of all the embedded HTML. If they "Smartify" it for 2.1, that would be a huge benefit.

Dennis

5
phillipd
Re:Why isn't smarty used in admin scripts
  • 2004/10/31 17:23

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Thanks for your answer! Have you got a sample admin module I can see to get started? Starting from agenda-x is jast about like starting from scratch.

Thanks!!

Doug P

6
dejadingo
Re:Why isn't smarty used in admin scripts
  • 2004/11/29 2:44

  • dejadingo

  • Just popping in

  • Posts: 71

  • Since: 2004/10/22


Seems like it's much more complicated than it should be to do this. I had my templates working outside the admin section of my module and now I want to put them under admin.

The big problem is that the admin area usually does not use the main XOOPS header file (AgendaX seems to be the exception here). So I had to find where XoopsTpl is being created/initialized and add that code to my header. However that is not enough.

- My admin header/footer display correctly.
- I can trace (with echo statements) down to the end where the template should activate.
- I can view the template through System Admin >> Templates
- I have updated my module as well as doing an uninstall/reinstall

The templates just don't work when invoked inside MyModuleDir/admin/index.php. I am running up against my deadline and getting very frustrated.

Any help would be greatly appreciated.

7
Dave_L
Re:Why isn't smarty used in admin scripts
  • 2004/11/29 5:09

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7



8
dejadingo
Re:Why isn't smarty used in admin scripts
  • 2004/11/29 8:45

  • dejadingo

  • Just popping in

  • Posts: 71

  • Since: 2004/10/22


Great, thanks - I'll try this.

Where I was stuck was
xoops_cp_header();
if (!isset(
$xoopsTpl)) {
   
$xoopsTpl = new XoopsTpl();
}
$xoopsOption['template_main'] = 'mymodule_admin.html';
include 
XOOPS_ROOT_PATH."/header.php";

ie. setting the admin header, followed by setting the template, followed by including the main XOOPS header.

In particular it seemed that including the main header file was a conflict with using xoops_cp_header() to set up the page theme for admin work.

Thanks again.

9
Mithrandir
Re:Why isn't smarty used in admin scripts

Do not include header.php in your admin-side "Smartyfied" scripts. All header.php does is:
a) Instantiate $xoopsTpl
b) Build Blocks
c) Check page cache settings

b) and c) are undesirable on an admin page and you instantiate $xoopsTpl yourself, so header.php is not necessary to include.

The administration will be smartified in XOOPS 2.1 so an admin page will be like this:
include '../../../include/cp_header.php';
xoops_cp_header();

//Module administration code including assignments to Smarty

xoops_cp_footer();
?>

10
Herko
Re: Why isn
  • 2004/11/29 9:30

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


The reason that the administration wasn't themed before is that this way you can't screw up your site and make it inaccessible (no blank pages due to bad themes). You always have the same (relatively safe) layout.

Herko

Login

Who's Online

352 user(s) are online (97 user(s) are browsing Support Forums)


Members: 0


Guests: 352


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits