Welcome Guest, Not a member yet? Register   Sign In
How do you allow for site preferences?
#1

[eluser]tomdelonge[/eluser]
I want the admin to login to the backend and be able to choose simple preferences, like "results per page" and such. I've heard of storing it in a db, but that seems slow (you'd have to read it every page display). What other ways do you guys accomplish this?
#2

[eluser]Thorpe Obazee[/eluser]
cookies?
#3

[eluser]tomdelonge[/eluser]
Sorry I mean like administration side (server side) not client side...
#4

[eluser]Phil Sturgeon[/eluser]
I do this in PyroCMS and it's not too bad. With a spot of DB caching and storing them results in the library object as you go (meaning two requests for site_name do not fire off too queries) I haven't really noticed an issue with speed.

I spend all day working with a CMS that runs about 50 database connections and runs over 100 queries just for basic page layouts and content... I really don't think a few 1 line SELECTs are going to hurt anything.

sql

Code:
CREATE TABLE `settings` (
  `slug` varchar(30) collate utf8_unicode_ci NOT NULL,
  `title` varchar(100) collate utf8_unicode_ci NOT NULL,
  `description` text collate utf8_unicode_ci NOT NULL,
  `type` set('text','textarea','password','select','select-multiple','radio','checkbox') collate utf8_unicode_ci NOT NULL,
  `default` varchar(255) collate utf8_unicode_ci NOT NULL,
  `value` varchar(255) collate utf8_unicode_ci NOT NULL,
  `options` varchar(255) collate utf8_unicode_ci NOT NULL,
  `is_required` tinyint(1) NOT NULL,
  `is_gui` tinyint(1) NOT NULL,
  `module` varchar(50) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`slug`),
  UNIQUE KEY `unique - slug` (`slug`),
  KEY `index - slug` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Stores all sorts of settings for the admin to change';

You can mostly ignore is_gui and module, they are just to stop it showing up on the interface and module is a way to break down settings into tabs.

lib
model

Hope thats of some help.
#5

[eluser]Thorpe Obazee[/eluser]
[quote author="tomdelonge" date="1246958144"]Sorry I mean like administration side (server side) not client side...[/quote]

oh...ok. Anyway, I don't see how it's gonna be different from normally putting it in the controller. You just have to do another query for it.
#6

[eluser]Phil Sturgeon[/eluser]
Well yes it would boil down to a query in the end but this is a nice standard way of doing it.

E.g:

Code:
$this->settings->item('site_name')
#7

[eluser]Thorpe Obazee[/eluser]
[quote author="Phil Sturgeon" date="1246971322"]Well yes it would boil down to a query in the end but this is a nice standard way of doing it.

E.g:

Code:
$this->settings->item('site_name')
[/quote]

I just got a deja vu when I saw that...
#8

[eluser]jdfwarrior[/eluser]
[quote author="Phil Sturgeon" date="1246966268"]I do this in PyroCMS and it's not too bad. With a spot of DB caching and storing them results in the library object as you go (meaning two requests for site_name do not fire off too queries) I haven't really noticed an issue with speed.

I spend all day working with a CMS that runs about 50 database connections and runs over 100 queries just for basic page layouts and content... I really don't think a few 1 line SELECTs are going to hurt anything.

sql

Code:
CREATE TABLE `settings` (
  `slug` varchar(30) collate utf8_unicode_ci NOT NULL,
  `title` varchar(100) collate utf8_unicode_ci NOT NULL,
  `description` text collate utf8_unicode_ci NOT NULL,
  `type` set('text','textarea','password','select','select-multiple','radio','checkbox') collate utf8_unicode_ci NOT NULL,
  `default` varchar(255) collate utf8_unicode_ci NOT NULL,
  `value` varchar(255) collate utf8_unicode_ci NOT NULL,
  `options` varchar(255) collate utf8_unicode_ci NOT NULL,
  `is_required` tinyint(1) NOT NULL,
  `is_gui` tinyint(1) NOT NULL,
  `module` varchar(50) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`slug`),
  UNIQUE KEY `unique - slug` (`slug`),
  KEY `index - slug` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Stores all sorts of settings for the admin to change';

You can mostly ignore is_gui and module, they are just to stop it showing up on the interface and module is a way to break down settings into tabs.

lib
model

Hope thats of some help.[/quote]

agreed.




Theme © iAndrew 2016 - Forum software by © MyBB