Gossamer Forum
Quote Reply
Global Help
For the this global
Code:
sub {
no strict;
my ($rec) = @_;
my $short;
my $comma;
my $cs;
my $desc = $rec->{'Description'};
my $id = $rec->{'ID'};
if (length $desc < 175) {
$short = $desc;
}
else {
$short = substr ($desc, 0, 165); $short =~ s/\s\S+?$//;
$cs = chop($short);
until ($comma eq " ") {
$comma = chop($short);
}
$short .= "...&nbsp;&nbsp;(<a href=\"<%detailed_url%>\">more</A>)";
}
return $short;
}

Instead of
<a href=\"<%detailed_url%>\">

I want to use these for the links

$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$link->{'title_linked'} = Links::Build::build('title_linked', $link->{'Full_Name'});

I do not know how to do this. Any ideas would be appriciated.
Quote Reply
Re: [jgkiefer] Global Help In reply to
Hi,

I'm not really sure what you're trying to do :/

Something like the below?

Code:
sub {
my ($rec) = @_;
my $short;
my $comma;
my $cs;
my $desc = $rec->{'Description'};
my $id = $rec->{'ID'};
if (length $desc < 175) {
$short = $desc;
} else {
$short = substr ($desc, 0, 165);
$short =~ s/\s\S+?$//;
$cs = chop($short);
until ($comma eq " ") {
$comma = chop($short);
}
$short .= qq{...&nbsp;&nbsp;(<a href="$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}">more</a>) };
}

return $short;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global Help In reply to
I am using a new links global on the home page and I am trying to shorten the description field with another global and end it with a "... more" link to the detailed page. Since the home page doesn't reconize the detailed_url tag I am trying to add one to the global. Since the new links global contains detailed links that work I thought I could just use them in the shortened description global as well. I will post both.

New links global
Code:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 5');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$link->{'title_linked'} = Links::Build::build('title_linked', $link->{'Full_Name'});
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}
Shorten description global
Code:
sub {
no strict;
my ($rec) = @_;
my $short;
my $comma;
my $cs;
my $desc = $rec->{'Description'};
my $id = $rec->{'ID'};
if (length $desc < 175) {
$short = $desc;
}
else {
$short = substr ($desc, 0, 165); $short =~ s/\s\S+?$//;
$cs = chop($short);
until ($comma eq " ") {
$comma = chop($short);
}
$short .= "...&nbsp;&nbsp;(<a href=\"<%detailed_url%>\">more</A>)";
}
return $short;
}
So I am trying to replace the

$short .= "...&nbsp;&nbsp;(<a href=\"<%detailed_url%>\">more</A>)";

With

$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$link->{'title_linked'} = Links::Build::build('title_linked', $link->{'Full_Name'});

I think I got the basic concept correct... well maybe, but I sure could use some help with this. Unsure
Quote Reply
Re: [jgkiefer] Global Help In reply to
Quote:
I am using a new links global on the home page and I am trying to shorten the description field with another global and end it with a "... more" link to the detailed page. Since the home page doesn't reconize the detailed_url tag I am trying to add one to the global. Since the new links global contains detailed links that work I thought I could just use them in the shortened description global as well. I will post both.


Hi,
I think a few things are going on here you should re-think in how you are doing this :)

First, you can't call globals from other globals (I just thought I'd say that).

Second, if you are going to print a link, or display a link, unless you only *really* only want the basics, you are better off calling the built-in routines to grab and format the link data, then print them to a template (or included template). Links have more properties now -- not just validated, but also isPaid, isExpired, etc -- and there will be *more* now that this format is available to be used and chained.

Third, there are a number of new-link and top-link routines already available. If all you are doing is trying to shorten the description, then there are also several (albeit older -- perhaps 2 years) threads on that. The "proper" way to display this would be to send the links_loop format data from the new_link global or function back to the template, then in the <%include new_link_format.html%> or whatever you call your format template, add a call to <%short_description Description%> which will return the shortened description. (actually you should use <%if Description%><%short_description Description%><%endif%> And all you need to do is locate the various code for shortening the description and add the short_description global.

Just a few suggestions. It's *way* too early for me, and I was up all night, so if you are still having trouble later on, maybe I can pull up the specific code fragments for you.


It's time to think in terms of Links SQL and CSS, and that means levels of includes, using loop_ variables to allow formatting within the templates not code, and to using the built-in routines for accessing data whenever possible.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Global Help In reply to
Yes that is what I was doing. I use the new links global to call the newest 10 links and display it with the links.html template (actually it is called links1.html). I use the short global to shorten the description in the links1.html. I found these from assorted older posts here on the forum.

All is well and everything works except displaying the detailed page link from the short code. I thought I could just add the link code into the short global like it is in the new links global but I don't know how to do this.

$short .= "...&nbsp;&nbsp;(<a href=\"<%detailed_url%>\">more</A>)";

I really appriciate your time and help.
Quote Reply
Re: [jgkiefer] Global Help In reply to
Thanks but I figured it out.