1
AAINC
Calling myql db in theme.html, please help!!
  • 2004/1/14 20:46

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


Hello,
This driving me crazy and I know it is probably simple.
I need a coffee break, bad.
Lets say I create a module with MySQL DB that I can update through admin.

Example of DB table:

Quote:

CREATE TABLE xoops_test (
name varchar(209) NOT NULL default ''
) TYPE=MyISAM;


How do I get the "name" field to display inside my theme.html???

Man I feel dumb.

2
svaha
Re: Calling myql db in theme.html, please help!!
  • 2004/1/15 11:41

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


When you feel dumb, then you feel down. When you are down, then there is only one way : UP !

3
Mithrandir
Re: Calling myql db in theme.html, please help!!

Everything dynamic displayed in theme.html needs to be fetched first.
If you want this to be displayed on EVERY page on your site, you will have to fetch it in the root/header.php and then assign it to Smarty with the function $xoopsTpl->assign('varname', $variable);

After that (provided $variable holds a value) you will be able to use <{$varname}> in your theme.html

4
AAINC
Re: Calling myql db in theme.html, please help!!
  • 2004/1/15 19:35

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18



I did it. I did it.

I figured it out.
twas real simple.

Brief background:
I wanted to make a Theme Control Panel based on Mtechnik (phpnuke) Theme control panel.

It lets you add up to 5 links and 3 messages through an admin area. The messages are a cross browser supported script. All displayed in theme.
I was having much trouble getting the theme.html to call the DB. The admin module side was no problem.
After weeks, nay, over a month of being stumped at not only this project but several others, it hit me like a ton o bricks. BRACKETS. Stupid little brackets. XOOPS needs them, XOOPS loves them, XOOPS is the Best.

<{php}><{/php}>

Example of calling db through theme.html

Quote:

<{php}>
global $xoopsDB;
$result = $xoopsDB->query("SELECT msg1 FROM ".$xoopsDB->prefix("archthemecp")." ");
list($msg1) = $xoopsDB->fetchRow($result);
echo $msg1;
<{/php}>



Is there a more compact way of writing this?

I am 90% finished with the ArchTheme Control Panel for XOOPS and will release version 1.0 this weekend.
I am modifying the default themes that come with XOOPS to utilize the theme control panel and they will be packaged with module. I will make a block to also display links.

You can see a working example at:
http://archangelartifacts.com

The messages and links below the logo are being drawn from the DB and are changed through the admin module.

I have put off finishing several themes til I figured this out. All future themes from AAINC will utilize this Control panel.

Be on the lookout for the ArchTheme Control Panel.
Coming to a Downloads section near you.

AAINC

ToDo:
Public Broadcast Message (sorta like phpnuke has) for admin to send a message to group specific.

TOP SECRET IDEA based on ancient chinese secret.



STUPID BRACKETS!!!!!

5
Mithrandir
Re: Calling myql db in theme.html, please help!!

Nice work, although I dislike logic in the presentation layer - that is, php code directly in the templates.

6
AAINC
Re: Calling myql db in theme.html, please help!!
  • 2004/1/15 19:52

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


Each theme.html has to call the info from the database. This can be used in any and all XOOPS themes. (just add some code.)

How would you call the DB directly through the theme.html?

addition:::
And have it work with any javascript within the theme.html.

7
AAINC
Re: Calling myql db in theme.html, please help!!
  • 2004/1/20 14:38

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


I have the admin side of ArchTheme Control panel 100% finished.
Is there a better way to call Db through Theme.html than this:

Quote:

<{php}>
global $xoopsDB;
$result = $xoopsDB->query("SELECT msg1 FROM ".$xoopsDB->prefix("archthemecp")." ");
list($msg1) = $xoopsDB->fetchRow($result);
echo $msg1;
<{/php}>


I am going to procede and convert the default themes to use this Control panel and release later today.


AAINC

Login

Who's Online

172 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 172


more...

Donat-O-Meter

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

Latest GitHub Commits