Gossamer Forum
Home : Products : DBMan : Discussions :

one db with mulitple templates

Quote Reply
one db with mulitple templates
Is it possible to have one database and have multiple templates to display records.
I don't mind if the admin and author levels are in one format, but I would like to have different displays of the public view.
For example, I am building a pet adoption database for several counties, I would like each county to have the display match each of thier homepage's layout, but pull the data from the same source.

Does this make sense?

Any help?

Alvy

Quote Reply
Re: one db with mulitple templates In reply to
(I applaud your use of the script! I like being part of anything to help our fuzzy friends. Smile)

Yes, it would be possible. You would need to be sure that all of the search results were from the same county. It would be best if you could require the county to be entered on the search form.

You mentioned "templates." Are you using the template mod? I don't know anything about that mod, so if you're using it, the rest of this post will be meaningless. Smile

If you're not using the template mod, make several copies of sub html_view_success -- one copy for each of the counties you're using -- and paste them all into the html.pl file. Leave one titled sub html_view_success and rename the others to sub html_county_success. (Subsitute the name of the counties for county.)

Delete all of the code in sub html_view_success. Replace it with

Code:

$sub = "html_$in{'County'}_success";
eval $sub;
Then make your changes for each county in its respective html_*_success subroutine.





JPD
Quote Reply
Re: one db with mulitple templates In reply to
Thanks!!!! Cool

I am NOT useing the Template mod... I was just using that vocabulary to describe that I want the exact feilds but with different layouts for each county.

I plan to have a field called "county" so they can see records only from their county, but the can choose other counties as well, or leave blank for all counties.

I will give your suggestion a go.
Could i do the same with sub html_home, sub html_view_search, sub html_view_failure?
So that every screen the public will see will match the county theme? Again i know that the author and admin will have to be the same and that is fine.


Thanks again
alvy



Quote Reply
Re: one db with mulitple templates In reply to
If you are going to allow users to get results from more than one county in a search, the code I gave you would cause you problems. Instead of what I gave you, put the following at the beginning of sub html_view_sucess:

Code:

if ($in{'County'} {
$sub = "html_$in{'County'}_success";
eval $sub;
return;
}
and leave the rest of sub html_view_success there for a "generic, all county" search result.

Yes, you could do the same with any of the other subroutines. Just make sure that the $in{'County'} part matches your input field exactly. IOW, if your field is called county, use $in{'county'}.



JPD