Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

new feature(s) suggestion

Quote Reply
new feature(s) suggestion
Hi,

As mentioned in another thread (219612), I would like to be able to show some pages that are not related to one of the current actions (like, search, add, modify). I would like to suggest two new features which would enable this (and many other things):

- there should be an action called 'nothing', which does nothing but showing the template
- it should be able to specify in the URL which template to use for a specific action. If no template is specified, the default is used.

This would enable me to create any number of pages using URLS like this:
'?db=data&do=nothing&tmpl=show_bargraph', '?db=data&do=nothing&tmpl=show_histo'.

GT, let me know what you think of these ideas and/or if there is another way for me to implement this using the current system?

http://www.bookings.org
Quote Reply
Re: [jaspercram] new feature(s) suggestion In reply to
A cleaner and more elegant way to accomplish this would probably be through the development of one or more plugins, but I can certainly sympathize with the fact that the method you describe would be simpler and quicker to implement.

One truly quick and dirty way to get the results you're looking for would be to designate a particular existing template (say home) as your "nothing" template and then just use a big <%if%> statement along with a url parameter to get the right data across.

In other words, use the urls:

?db=data&do=home&special=show_bargraph
?db=data&do=home&special=show_histo

And then your search_results template could have:

<%if special == 'show_bargraph'%>
do the bargraph stuff
<%elseif special == 'show_histo'%>
do the histo stuff
<%else%>
do the regular home stuff
<%endif%>

I admit this is an awkward, inelegant, and slow solution. But it might be easier for a newish user than developing a bunch of plugins. Just a thought.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] new feature(s) suggestion In reply to
In Reply To:
A cleaner and more elegant way to accomplish this would probably be through the development of one or more plugins, but I can certainly sympathize with the fact that the method you describe would be simpler and quicker to implement.
How would the plugin look? When you have to specify an fake action in your URL to activate the plugin (like '?do=add&special=ignore_add_but_do_nothing_instead'), I think the solution would definitely be less elegant. Furthermore, from what I understand from plugins, it is not possible to overwrite the template which is going to be selected.

In Reply To:
One truly quick and dirty way to get the results you're looking for would be to designate a particular existing template (say home) as your "nothing" template
Ah, I didn't know what home did, but maybe home is already some kind of do nothing action. That would definitely solve have the problem!

In Reply To:
just use a big <%if%> statement along with a url parameter to get the right data across.
Good point. Not very elegant, but workable for now.

Thanks for your help!

Jasper

http://www.bookings.org
Quote Reply
Re: [hennagaijin] new feature(s) suggestion In reply to
I had two feature requests:
  • Add a nothing action - already supported Sly

  • Allow multiple templates for a single action


In my initial email, I gave a suggestion for the second issue. Another option to solve it, is to allow recursive template sets. This could look a little bit like what is provided in Links SQL (where there can be a local directory which would overwrite the defaults). The directory structure of template sets could look like this

Code:
admin/templates/
default/
my_project/
users/
table1/
table2/
table3/
staff/
table4/
table5/
table6/

When the script needs a template, it would first look in the directory that is specified in the setup section. If the template can not be found, it will look at the parent directory. This will repeat until the script finds the template.
An advantage of this solution is, that you never have to specify a specific template in the URL; the script would automatically select the appropriate template. A disadvantage is that it is still impossible to provide two templates for a specific action / table combination. What do you all all think of this solution, compared to my previous one?

Jasper

http://www.bookings.org
Quote Reply
Re: [jaspercram] new feature(s) suggestion In reply to
Quote:
How would the plugin look? When you have to specify an fake action in your URL to activate the plugin (like '?do=add&special=ignore_add_but_do_nothing_instead'), I think the solution would definitely be less elegant. Furthermore, from what I understand from plugins, it is not possible to overwrite the template which is going to be selected.


I'm pretty sure you could write a plugin that developed a new action, so that you could have simply:

?db=data&do=show_histo

All of the subroutines in Home.pm relate to different actions (e.g. home, modify_search_form, search_results, login, etc.) and call different templates. A plugin that created a new subroutine in Home.pm could have its own "do" parameter and its own template. That's why I think it would be the most elegant solution.

Quote:


Ah, I didn't know what home did, but maybe home is already some kind of do nothing action. That would definitely solve have the problem!


Home is supposed to be for the database's home page, but you should use it however you see fit.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [jaspercram] new feature(s) suggestion In reply to
Hi,

I think I found an obvious way to inlcude arbitrary templates (and even have a default). Most of your probaly know it, but for those of you who are looking for an answer (like me), here it is:

In the URL, pass a variable with name tmpl and the name of the template as value:
Code:
db.cgi?db=mytable&do=home&tmpl=mytemplate.html

The file home.tmpl should look (roughly) like this:
Code:
<%if tmpl%><%include $tmpl%><%else%>

... default behaviour ...

<%endif%>

If you would like to have a standard header and footer around templates, the file could look like this:
Code:
<%include header.html%>
<%if tmpl%><%include $tmpl%><%else%>

... default behaviour ...

<%endif%>
<%include footer.html%>

Have fun, Jasper

http://www.bookings.org