Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Basic Links2 Concepts.....Am I On the Right Track?

Quote Reply
Basic Links2 Concepts.....Am I On the Right Track?
 
Hi,

First the good and bad. I have downloaded and done the quick install of Links2 and everything went
smoothly. The bad is that the script is pretty advanced and comes with almost no documentation other than the install instructions. I'm pretty much a newbie to Perl scripts installation and customisation but I still
want these links to integrate nicely into the site I'm working on design wise.

I started investigating the template system included with Links2. I was hoping it would be pretty easy and it
is but there are some limitations to using the template system. It appears to me that to really do some
customising in the look of Links2 that you have to fiddle with site_html and go beyond site_html_templates.
Since I don't really know Perl I need some help altering the HTML inside the site_html file.
I can see that the HTML code snippets always follow 'output' but i'm not sure where to stop adding the html
code I want to add to make the Categories and Links look the way I want using my own template.
What is this '\n' I see in Perl scripts? When is it necessary to use it and why?
Am I right in that when I look at the templates included with Links2 that where it says <%category%>,
that the script builds the category according to the html code included in site_html in the category section?
I took a tour of some of the sites using Links2 and found one that makes Links2 appear like a UBB forum,
I want to try this design. In this design he has split the category into a table with individual cells for
the title, number of links, description etc. So any help editing the site_html file to get this layout would be much appreciated.

I also have some categories that will need some different fields(not sure if this is the term) for people to
check off when they add a link to my directory. Let's say I wanted to make one category a sorta personals
biography section.......just a description isn't enough ........ i would want them to check off if they were
M or F......city they live in......age...... things like that. How do I add new 'fields' or 'records' in the add
page and then how to make them show up in the html output on my pages?

Lastly, banner ads. For now I am fine with just using static ads. But reading through the forums am I to understand that most banner ad scripts can't be used from within a CGI script like Links2 which generates
static HTML pages? I was hoping to one day add a PHP or Perl banner system and thought using the template system I could just add the banner add code in my template. It's not that easy right? Cuz I see a bunch of discussions of mods for using banner ad rotators. It got me to thinking tho, on pretty much most
sites on the Net like the search engines like AltaVista they do seem to be using CGI generated ad systems
integrated into their CGI driven search engine. I guess I just don't understand why one CGI script can't
be inside another one.

If I'm way off the mark in understanding how Links2 works please let me know now before I go off causing
alot of grief for myself. It's better to have the concept down before really digging into something, to know
the limitations.

Thanks much

MTommy


Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
You seem to be pretty much on the right line.

In Reply To:
What is this '\n' I see in Perl scripts? When is it necessary to use it and why?
\n is a newline. It is similar to a <BR> in html except it is used when the header is text/plain, not text/html and is used to add new lines in text files etc...

So if for example I printed a tex/plain header and used a <BR> tag then the tag would just show up on the page but using \n would create a newline.

In Reply To:
Am I right in that when I look at the templates included with Links2 that where it says <%category%>,
that the script builds the category according to the html code included in site_html in the category section?
Yes, along with the accompanying perl code.

Bascially the cgi produces the output and just substitutes the tags for that output, so if you added a new tag to the globals in site_html_templates.pl like:

Code:
mytag => &mysub,
...this tells links2 that if <%mytag%> is found in the templates, then call &mytag sub and replace the tag with the output of the sub.

Here is an example of mysub....

Code:
sub mysub {
my $var = 'This is my tag!';
return $var;
}
Put <%mytag%> in one of the cgi templates like add.html (just so you don't have to rebuilt to see the outcome) and then go to add.cgi in your browser. Wherever you placed the tag in add.html, you should see "This is my tag".

Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
 
THanks for the answers Paul.
About the "\n" thing, how do you know when a line break is needed in Perl?

Do you know how to add new fields to specific categories? So they show up in the add.cgi for that category and then in the output HTML.

thanks again

MT

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Hi,

A \n is needed wherever you feel it is (at a basic level).

Take this for example.....

print "Hello my name is Paul. Below is my age:";
print "My age is 20";

...this would print...

Hello my name is Paul. Below is my age:My age is 20

...now that looks ugly so a newline is needed...

print "Hello my name is Paul. Below is my age:\n";
print "My age is 20";

...which would print....

Hello my name is Paul. Below is my age:
My age is 20

Using \n's becomes more important when using more complex code such as sending emails with MIME attachments - a \n in the wrong place will give an undesired result.

To add a new field, open up category.def and add a new field to the list. That field will then show up in the admin panel when you add a new category. The tag for the new field would have to go in category.html.



Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Paul

This is true for formatting of HTML output, but the \n control wouldn't do zilch to the layout of your page in a web browser.

You will still need to code:

print "Hello my name is Paul. Below is my age:<BR>\n";
print "My age is 20";


Cheers

Wil

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
No you don't. As I mentioned I was talking about text/plain only.


Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
 
Thanks for answering my newbie questions Paul.

Hmm......... not sure if what you are telling me will do what i'm trying to accomplish.

For example, let's say I have a big Links2 directory, in it, i have a category called FindAFriend with sub
cats like Males18-25, Women50Plus etc, Kids12andUnder........... for the adult groups I would want to
add a field where the link would have a Yes or No for Do You Smoke and Do You Drink? ......now for the
Kids category I wouldn't want this field to show up in their links in the output.
From looking at how and where Links2 builds the individual links it looks to me that it will include ALL fields
it finds in the database.

Am I right? Or is there another place in another file which addresses how a link will look in an individual category? The site_html seems to be a global type thing that affects everything. I know there is a mod
to make each category look differently using templates but I'm talking about different categories having
different information fields.

My head's spinning, need a lie down LOL

MTommy

Thanks!

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Hmm...

You could add a little radio button in add.html saying:

Select if over 18

...if selected a select list will appear using javascript and will allow then to enter if they smoke or not.

You would just need to add a new field to links.db called "Smoke" and then obviously work out the javascript.

Have I understood what you are asking?

If so, I will try to come up with the javascript for it.

Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
 
You sorta understood what I'm trying to do. The smoker/non smoker field was just a sample.
The crux of what I am asking is how or even if it's possible to have some categories have different
content in the links for that category.
I'd like my installation of Links to give people some good information laid out clearly not just a Title and
a bland looking description that the link submitter gives me about his service.

Another example........ I have a Links2 directory which has the default fields Links2 comes with......
Title......Description....Hits....Rating.......... that's cool for most of my categories and subcategories....
BUT I have one category 'Graphics Tutorials' where I have listings of many tutorials for Photoshop and PaintShopPRo on the Web.....in this category I want to have a field where I or the person who submits the link can select whether it is a Photoshop OR a PaintshopPro tutorial and I also want for me or whoever
submits the link to be able to mark that tutorial for degree of difficulty Beginner, Intermediate or Expert.
I want that information to show up in the links in that category.
I don't want these two fields to show up in the other categories.
How do I do it? From my newbie's eye view of Link2 I see how the links are created in the sub in site_html
and it looks to me as if these two new category specific fields will show up in all the categories.

thanks

MTommy

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Right,

Yes it can be done. It may be a little tricky though.

You'd have to add new fields to the database for Smoke, Tutorial-Type or whatever it is you need. Then you'd need the enhanced template parser and use something like this in the link.html template...

Code:
<%if Category eq 'Adult'%>
<%if Smoke eq 'yes'%>
I smoke
<%endif%>
<%if Smoke eq 'no'%>
I don't smoke
<%endif%>
<%endif%>
Don't quote me on that though....


Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
But what use is coding output for text/plain for Links? All output bar emails is done through a web browser? Or am I mistaken?

Wil

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Wil please read the original question...

In Reply To:
What is this '\n' I see in Perl scripts? When is it necessary to use it and why?
Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
Paul

Read and understood. I also noticed that the question had developed into ways of customizing links for browser output.

Therefore I just wanted to highlight the fact that you needed both character control and html coding to achieve desired browser output while preserving html layout.

Not an unreasonable response, surely?

Wil

Quote Reply
Re: Basic Links2 Concepts.....Am I On the Right Track? In reply to
No not unreasonable at all.

Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/