Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

3rd party template mods from 2.0 to SQL

Quote Reply
3rd party template mods from 2.0 to SQL
First question:

How does the template.cfg and site_html_templates.pl file fit into the SQL version?

(I'm going to try to limit each message thread to one basic/major question.)
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
I don't know if this is the right way, or if there is a way to keep the templates.cfg, but I got it all working.

1) take the %global descriptions from site_html_templates.pl and put that into the HTML_Templates.cgi file, making sure to watch the ',' (on every line but the last) and to delete duplicate lines, keeping the new $LINKS(etc) format for the URLs.

2) take the templates.cfg file, and copy it to the top of the HTML_Templates.cgi file, putting a 'my' in front of EVERY variable. (in the following global section, every $variable (right side) assigned to a global field (left side) needs to be defined above the my %global with a 'my'

3) if you have commented out any variables in the templates.cfg but are still passing them in the %globals, you will need to uncomment them. *ALL* variables have to be defined.

...

I'm sure there is a way to make template.cfg an include package, but actually, putting everything in the one file is probably faster, and makes maintaining easier -- though it doesn't make switching between 'looks' as easy.

I'm happy, I'm up and running the SQL and I did it all myself Smile

Kudos to Alex's code....

Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
That's probably the best way. Unfortunately since the new one is running under use strict, you need to declare everything with my(), can't have lots of globals everywhere. This is neccessary to ensure the script works well under mod_perl.

Cheers,

Alex
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
I thought I once saw a similar discussion on this, but I can't find it now. Is this still the best method of transferring the site_html_templates.pl and templates.cfg setup from 2.0 to SQL? That's pretty much the way I'm headed with it, although I think I might run into problems with my

Code:
$site_footer = qq~</TD></TR></TABLE>~;
$file2 = "/big/dom/xrun_down/www/pointer3.txt";
open (FILE, $file2) or die "Can't open $file2 ($!)";
@lines = <FILE>;
close FILE;
foreach $line (@lines) {
$site_footer .= $line;
}
code I currently usein site_html_templates.pl for headers and footers throughout the site. I imagine I'll have to use my() in front of the first $site_footer declaration?

Also, I'd just like to publicly thank Alex for being very helpful in installing Links SQL for me and answering my questions promptly. Smile

Dan
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
Hi Dan, funny - I had just been reading through the post which I think you are refering to. You can find it at
http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000027.html

------------------
~ ~ ~ ~ ~
Karen
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
This is still the _only_ way to handle it, but you also need to realize that it's now %GLOBALS not %globals ...

If you are using the templates.cfg format, you need to declare each of the first occurances of the variable with "my" -- That's about all.

The format of the hash is the same.

Declare all your variables, and then insert them into the hash for passing.

If you have specific needs, check the more recent posts -- and the FAQ -- there are some specifics on modifying variables for certain needs.






------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
 
Quote:
keeping the new $LINKS(etc) format for the URLs
I think I misread that line to mean that is the pattern that must be followed for all of the globals (don't worry, I was aware of the capitalization Smile ). After a good deal of confusion, I finally caught on to the problem. The thread Karen pointed out eventually made me realize that the global tags are still declared the same as they were before...

Now that that's working, I can try the includes!

Dan
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
The code snippet you posted seems to just do an include. You can just use:

<%include filename.txt%>

in your template and it will pull it in for you.

Cheers,

Alex
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
Thanks Alex. I was just coming back to post that that code snippet doesn't work in SQL...
The reason I had it set up that way in 2.0 was so that the single header and footer file that is used throughout my site could be pulled into the Links pages in one place. It worked well for appending some HTML code to the include (due to the way I use the header in a couple of sections to individualize pages) before adding it to the templates.

It's easy enough to use the <%include footer.txt%> method, but that means I have to edit extra files whenever I make a change to the site. Not the end of the world, and always something I can change if I figure out a solution.

Dan
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
Karen -- thread 27 was before I started adding to the FAQ... but that's been added, and keyworded.

Please see if it comes up on searches for what you were looking for originally (so someone with the same questions you had will find it!) If not, tell me what keywords you were looking for, and I'll add them.

Thanks!!


------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
pugdog, I've just been at a loss Frown Trying to watch for instructions, how-to's on using a Yahoo! style display. Something like this
Code:
Category
subcat1 subcat2 subcat3 ... (more)
and I'm at a real disadvantage since the sql version is my first exposure to the links program.

Everything coming across the forums is for moving links2 mods to sql and very hard to understand/follow because it is dealing with changing one programming language to another programming language.

I'm a newbie to programming at all (working hard on it though!) and realizing that my links db needs would far exceed flat file, opted to go for the sql and learn it.

Just really leaves me stuck though - Installing, learning, customiving the flat file program and then trying to update to the sql version means I won't have a working site half of forever. Smile Although, it's really looking like I won't have a customized working site for that long either! Smile

BTW - are you feeling better? Hope so!



------------------
~ ~ ~ ~ ~
Karen
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
My tail's starting to wag Wink If that means anything. <G>

But SQL is not a "programming language" as much as it's a way to get data out of the database. perl is still the language, but rather than using fopen and <FILENAME> to read and get data, and complex code-based search/sort algorithms, the SQL database can do much of that for you. The way to interact with the database from perl, is to use the DBI BD module (Database Independent atabase Dependent) module. It acts as an interface between perl, and the database you are trying to use.

On top of that interface, Alex has written an engine DBSQL.pm -- think of the DBD BI interface as DOS Command line, and DBSQL.pm a Windows style graphical interface.

Rather than calling all the low-level database functions, you can use simple (relatively) Object Oriented calls.

The real difference between Links 2.0 and SQL is that Links 2.0 is doing a heck of a lot of work less efficiently that the SQL database does for you fairly efficiently.

For most intents and purposes, your interaction with SQL directly will be very, very limited, and usually just changing the order (or data) requested from a query. Much of that has even been abstracted to the Links.pm file.

So, really, many, many modifications to the program are made in the Links.pm file and the templates.

"GLOBAL" variables and changes to what each template can do are set up in the HTML_Templates.pm file in the Links subdirectory.

For all purposes other than "hacking" those are the only files you need to edit or mess with.

As you have read, if you make a lot of changes to the database, sometimes you have to save or manually edit the .def files, but not often.

There are some really good books on perl and mySQL, (they are listed in the FAQ area) and I think there are 4 I have listed there. They are pretty much "essential". Added to that is he RegEx book.

If you are running on Linux or Solaris you need at least one, maybe two different sysadmin books (each will have a different view of important stuff, and different ways of attacking it). BSD there is the book that comes with the CD ROMS.

The first step to solving, or working on, a computer (or really any) problem is defining it. Defining it as simply and clearly as you can. Not just "I want the program to do x, y, z" but "I need the x-field to be added in the add.html (and where else do I need it?, what databases have to change, where do I need to pass it?)

Stuff like that.

The more you keep plugging away at this, the more you'll understand.

First step is to modify and fix up the templates to make your site look the way you want, then add fields you need added or changed, then try to work on code changes.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
pugdog, you never cease to amaze me with your ability and willingness to go into incredible detail and keep in easy to understand. Smile

Karen, with regards to your Yahoo-style subcategory question, I made use of a very simple alternative. The original mods didn't seem to give much control over which subcats you want listed, but I think Jerry's latest mod addressed that. At any rate, I figured it's preferable to have complete control, i.e. being able to choose which subcats to list, which to abbreviate, andin what order. The easy way to do this is just put them into the category description as HTML links. I set the font size for descriptions to "1" anyway, since I only use it to add to a category that must be abbreviated due to length. Seems to work just fine for me. Once you've set up such links on the home page, they're not too likely to require changing, so a static approach should be ok.

Dan
Quote Reply
Re: 3rd party template mods from 2.0 to SQL In reply to
pugdog, Dan - I too am amazed at some of the responses in the forums. The template modifications are the easy part - HTML & graphics are two areas I work very well in.

The Unix end of things isn't a big problem either. As with everyone, I would guess time is the critical element. I purchased Links for a personal project and it is hard to set aside the time needed for learning how to make the program do what I would like it to do. Clients get first dibs on time. Smile DBManSQL looks like it is "out the window" for a while (for me) until there are far more users and far more discussion on putting the program to work!

I have purchased several books and am making headway on several of them - mSQL & MySQL, CGI/Perl Cookbook (Eliot often praises that one) and Perl in a Nutshell - went broke last trip to the city (about 220 miles away). Yes, I know you can get books online, just isn't the same - although I have bookmarked JPDeni's bookstore for future reference.

I routinely subcontract programmers for client's sites, just isn't enough time to do it all! Looks as though I'm going to have to learn it myself in order to complete my project though since there isn't anyone to pass the cost off to.

I'm going to be gone for a full week. If you spot any intro threads getting going would'ya make a note of them for me? I'd sure appreciate it - I know this board is going to be jam-packed when I return, it'll be a chore sifting through to try figuring out what's within my (very limited) knowledge area and what's way over my head. Thanks!

------------------
~ ~ ~ ~ ~
Karen