Static Pages headline links from "field" selection

Archive of notes and cross input on Dev versions of Coranto (1.25.1 and Older)

Moderators: Dale Ray, SrNupsen, Bluetooth, Jackanape

Static Pages headline links from "field" selection

Postby Gmaniac » Thu Jun 27, 2002 3:59 pm

ok its simple but not very accurate..

i am using static pages and i have a profile which create static links for my headlines
i have also a news field named "expertsname" (the name of the expert, like john, nicolas, george bla bla bla) this is a list box created in npconfig.pl by hand

Code: Select all
$FormFieldsName{'expertsname'} = "Expert Name";
$FormFieldsCustom{'expertsname'} = qq~
<select name="newsimage">
<option value="" selected>
<option value="kentritas">Stelios Kentritas</option>
<option value="koulopoulos">Thomas Koulopoulos</option>
<option value="tzokas">Nikolaos Tzokas</option>
<option value="sellis">Timos Sellis</option>
<option value="kiohou">Naya Kiohou</option>
</select>
~;


this code is ok.

my question is if the sub below in ndisplay.pl can work...
(both $fname & if - else together)

Code: Select all
sub DoExpertHeadlines {
       $newshtml = qq~~;
       $fname = &NCMakeFName;
       if ($expertname == "kentritas") {
       $newshtml .= qq~
<A CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</A>
~;
} else  if ($expertname == "koulopoulos") {
       $newshtml .= qq~
<A CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</A>
~;
} else  if ($expertname == "tzokas") {
       $newshtml .= qq~
<A CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</A>
~;
} else  if ($expertname == "sellis") {
       $newshtml .= qq~
<A CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</A>
~;
} else  if ($expertname == "kiohou") {
       $newshtml .= qq~
<A CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</A>
~;
}
}


acctualy i want the links target the static pages of the specific expert

i dont know perl but i can make some experimentations
Gmaniac (A Greek, Coranto Experienced User)
Gmaniac
 
Posts: 291
Joined: Mon Jan 15, 2007 11:05 am
Location: Hellas - Greece

Postby AeroSoul » Thu Jun 27, 2002 4:27 pm

instead of:
Code: Select all
} else if ($expertname == "...") {
use:
Code: Select all
} elsif ($expertname eq "...") {
note the "eq" instead of "==" (which is used only for comparing numbers).
Keep the dream alive!
User avatar
AeroSoul
 
Posts: 562
Joined: Sat Mar 09, 2002 10:30 pm
Location: Toronto, Canada

thank you

Postby Gmaniac » Thu Jun 27, 2002 5:39 pm

Thank you i will try it and i will post a feedback for the results
Gmaniac (A Greek, Coranto Experienced User)
Gmaniac
 
Posts: 291
Joined: Mon Jan 15, 2007 11:05 am
Location: Hellas - Greece

Postby AeroSoul » Thu Jun 27, 2002 5:45 pm

there are a few other errors in your code. generally this should work:
Code: Select all
sub DoExpertHeadlines {
   $fname = NCMakeFName();
   if ($expertname eq 'kentritas') {
      $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
   } elsif ($expertname eq 'koulopoulos') {
      $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
   } elsif ($expertname eq 'tzokas') {
      $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
   } elsif ($expertname eq 'sellis') {
      $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
   } elsif ($expertname eq 'kiohou') {
      $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
   }
}
Keep the dream alive!
User avatar
AeroSoul
 
Posts: 562
Joined: Sat Mar 09, 2002 10:30 pm
Location: Toronto, Canada

Postby kriko » Fri Jun 28, 2002 3:09 pm

only thing is that why you have it checking the expert names, when every output produced is the same
<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>

You just may put it as:
Code: Select all
sub DoExpertHeadlines {
   $fname = NCMakeFName();
   $newshtml .= qq~<a href="$thisURL/$fname" class="LeftLink">$newsquestion</a>~;
}


but if you want the links to be different, depending on the author then nevermind.
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

the solution (well... not perfect but it works)

Postby Gmaniac » Mon Jul 01, 2002 9:44 am

thank you for your help to make this work.
i have spend a little time to fix my code errors and other things but the sub has an unusual behavior...

i decide to separate every expertname to its own sub
at first i make all the experts names as a news profiles with Newscat

KentritasHeadlines
KoulopoulosHeadlines
TzokasHeadlines
etc...

in my ndisplay.pl
i use this sub
Code: Select all
sub DoKentritasHeadlines {
     $newshtml = qq~~;
     $fname = &NCMakeFName;
     if ($expertsname eq "kentritas") {
     $newshtml .= qq~
<a CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</a>~;
} else {
$newshtml .= qq~~;
}


and it works with the other names as well

conclusion: a bit more coding but stable.
:lol:

p.s.: i don't understand why both of you remove the
$newshtml = qq~~; line, in the previous posts.
Gmaniac (A Greek, Coranto Experienced User)
Gmaniac
 
Posts: 291
Joined: Mon Jan 15, 2007 11:05 am
Location: Hellas - Greece

Re: the solution (well... not perfect but it works)

Postby kriko » Mon Jul 01, 2002 10:12 am

gmaniac wrote:
Code: Select all
sub DoKentritasHeadlines {
     $newshtml = qq~~;
     $fname = &NCMakeFName;
     if ($expertsname eq "kentritas") {
     $newshtml .= qq~
<a CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</a>~;
} else {
$newshtml .= qq~~;
}

p.s.: i don't understand why both of you remove the
$newshtml = qq~~; line, in the previous posts.


Why not to use
Code: Select all
sub DoKentritasHeadlines {
     $fname = &NCMakeFName;
     if ($expertsname eq "kentritas") {
     $newshtml .= qq~
<a CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</a>~;
}


Cause the
$newshtml .= qq~~;
does not do anything, there is no point of leaving it, also there is no point of leaving
} else {
$newshtml .= qq~~;
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

you'r right

Postby Gmaniac » Mon Jul 01, 2002 12:15 pm

i see..... the line $newshtml = qq~~; has not a supplementary function.
but i use the code below
Code: Select all
} else {
$newshtml .= qq~~;
}

because when i have to choose another expertname from the list.
newspro creates records in all txt files

example:
newspro creates the
KentritasHeadlines.txt
which has all the headlines from Kentritas posts, when another person make a post, his/her subject will be creted in his/her txt file but this subject will be also posted into KentritasHeadlines.txt or every other person txt file because there in no exclusion from the other exeprtsname variable.

i hope to think correct and not make myself tiresome.
Gmaniac (A Greek, Coranto Experienced User)
Gmaniac
 
Posts: 291
Joined: Mon Jan 15, 2007 11:05 am
Location: Hellas - Greece

Postby kriko » Mon Jul 01, 2002 12:20 pm

First of all, does it work at the moment, are you satisfied with it?

Also, the sub code was wrong or you didn't paste everything, the sub is missing one last } from the end.

If I understand you correctly then you might also use the following code:
Code: Select all
sub DoKentritasHeadlines {
     $fname = &NCMakeFName;
     if ($expertsname) {
     $newshtml .= qq~
<a CLASS="LeftLink"  HREF="$thisURL/$fname">$newsquestion</a>~;
     }
}
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

oh this is the best

Postby Gmaniac » Mon Jul 01, 2002 4:01 pm

sorry about the missing } its my fault

yes the code works fine :wink:

thanks for your time and patience.
Gmaniac (A Greek, Coranto Experienced User)
Gmaniac
 
Posts: 291
Joined: Mon Jan 15, 2007 11:05 am
Location: Hellas - Greece


Return to Coranto Development Archives -- 1.25.1 and Older

Who is online

Users browsing this forum: No registered users and 2 guests

cron