Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[ FREE PLUGIN ] ULTRAGlobals - Collection of Globals and routines

(Page 9 of 10)
> > > >
Quote Reply
Re: [Andy] Ideas please In reply to
Hi Andy,
with the following code I'm trying to print 3 random links of one category,
I don't want the whole include.html disyplayed, only the title and the image stored in the field "banner".
The url should be in title and in the image!

Code:
<%Plugins::ULTRAGlobals::Random_Links(3,'672')%>
<%if Random_Loop.length%>
<%loop Random_Loop%>
<%include link.html%>
<%endloop%>
<%endif%>

Can you tell me the the code?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Ideas please In reply to
Why not just make a new template called link_basic.html, and change the "include" to use that template instead? Wink

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] Ideas please In reply to
It's only for a random image in the rightsidebar, and I don't want to have another link.thml for it :-)

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Ideas please In reply to
Ok, so why bother even doing an include then? Whistle

Just do something like:

Code:
<%Plugins::ULTRAGlobals::Random_Links(3,'672')%>
<%if Random_Loop.length%>
<%loop Random_Loop%>
<%Title%>
show whatever it is you want here

<%endloop%>
<%endif%>

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] Ideas please In reply to
Yes I know, but the "show whatever it is you want here is the problem :-)
I want to show an image from the database field "banner" with the link from the database.


Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Ideas please In reply to
Hi,

Ok, please explain more. Where is the banner "stored"? You havn't really explained that - I thought it was just another field in your glinks_Links table ;)

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] Ideas please In reply to
O.K. found a solution by myself.
Tell me, if it there are some senseless parts :-)

Code:
<%Plugins::ULTRAGlobals::Random_Links(1,'672')%>
<%if Random_Loop.length%>
<%loop Random_Loop%>
<a href="<%URL%>" target="_blank"><%Title%></a><br />
<a href="<%URL%>" target="_blank">
<img border="0" src="<%Banner%>" <%if Width%>width="<%Width%>"<%endif%> <%if Height%>height="<%Height%>"<%endif%> title="<%Title%> >"</a>
<%endloop%>
<%endif%>

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Ideas please In reply to
Quote:
<%Title%>
show whatever it is you want here
&
Quote:
<a href="<%URL%>" target="_blank"><%Title%></a><br />
<a href="<%URL%>" target="_blank">
<img border="0" src="<%Banner%>" <%if Width%>width="<%Width%>"<%endif%> <%if Height%>height="<%Height%>"<%endif%> title="<%Title%> >"</a>

Both quotes above are the same thing and exactly what Andy suggested.

Where he writes 'show whatever is you want here' means, you can use link properties to design the output you desire.

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [Matthias70] Ideas please In reply to
Sure, thats fine (its what I suggested ;))

I'd change it a little bit though - as no point in having 2 <a href bits .. as it just adds more text than you need)

Try:

Code:
<%Plugins::ULTRAGlobals::Random_Links(1,'672')%>
<%if Random_Loop.length%>
<%loop Random_Loop%>
<a href="<%URL%>" target="_blank">
<%Title%><br />
<img border="0" src="<%Banner%>" <%if Width%>width="<%Width%>"<%endif%> <%if Height%>height="<%Height%>"<%endif%> title="<%Title%>" />
</a>
<%endloop%>
<%endif%>

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] Ideas please In reply to
OK, Thanks for your help

Matthias
gpaed.de
Quote Reply
Re: [Andy] Ideas please In reply to
Hi Andy,

I have a problem with List_Links.
I would like to obtain only the links validated.
isValidated => 'Yes'

A possible solution?

Still a great plugin! :)

Mick

Quote Reply
Re: [MJ_] Ideas please In reply to
Hi,

Have you tried:

Code:
<%Plugins::ULTRAGlobals::List_Links('isValidated','=','Yes','Title ASC',10)%>
<%if cond_loop_link.length%>
<%loop cond_loop_link%>
<%include link.html%>
<%endloop%>
<%endif%>

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] Ideas please In reply to
Hi Andy,

In Fact, I use already a condition.

Code:
<%Plugins::ULTRAGlobals::List_Links('City','LIKE','%MyCity%','Add_Date DESC',10)%>

Is It possible to use several conditions?

<%Plugins::ULTRAGlobals::List_Links('isValidated','=','Yes','City','LIKE','%MyCity%','Add_Date DESC',10)%>

Thanks again! :)

Mick
Quote Reply
Re: [MJ_] Ideas please In reply to
Hi,

In /admin/Plugins/ULTRAGlobals.pm, find the function "sub List_Links", and replace the code with the following:
Code:
sub List_Links {

my ($sort_order,$limit) = (shift,shift);
my @fields_to_sort = @_;

$sort_order ||= "Title ASC";

my $tbl = $DB->table('Links');
if (defined $limit) {
$tbl->select_options(qq|ORDER BY $sort_order LIMIT $limit|);
} else {
$tbl->select_options(qq|ORDER BY $sort_order|);
}

my $cond = new GT::SQL::Condition;
foreach (@fields_to_sort) {
my ($field,$operator,$val) = split /::/;
$cond->add($field,$operator,$val);
}
$cond->bool('AND');

my $sth = $tbl->select( GT::SQL::Condition->new($field,$operator,$val) ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
$hit = Links::SiteHTML::tags('link', $hit);
push @loop, $hit;
}

return { cond_loop_link => \@loop }

}

Then try calling using:

Code:
<%Plugins::ULTRAGlobals::List_Links('Title ASC',10,'isValidated::=::Yes','Foo::LIKE::%bar%')%>

The 1st paramater is the "sort" order for the results. The 2nd paramater is the "limit" of how many results to get. The ones after that are the different field types you wanna add to the condition.

The above would do:

Code:
isValidated => Yes
Foo LIKE '%bar%'

Each condition needs to be given a new value... for example:

Code:
'Foo::=::bar','Test::<=::5'

..etc

Totally untested, but should work Smile

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] Ideas please In reply to
Hi Andy,

I obtain the error:

Global symbol "$field" requires explicit package name at ULTRAGlobals.pm line 2106.
Global symbol "$operator" requires explicit package name at ULTRAGlobals.pm line 2106.
Global symbol "$val" requires explicit package name at ULTRAGlobals.pm line 2106.

line 2106 :

Code:
my $sth = $tbl->select( GT::SQL::Condition->new($field,$operator,$val) ) || die $GT::SQL::error;

An idea?

Thanks!

Mick
Quote Reply
Re: [MJ_] Ideas please In reply to
Oops, change:

Code:
my $sth = $tbl->select( GT::SQL::Condition->new($field,$operator,$val) ) || die $GT::SQL::error;

to

Code:
my $sth = $tbl->select( $cond ) || die $GT::SQL::error;

That shouls fix it Wink

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] Ideas please In reply to
Great ! Thanks ! :)

I also try to use your upper_or_lower global with Edit_Title_Full_Name.

<%Plugins::ULTRAGlobals::Edit_Title_Full_Name(upper_or_lower('lower',$Full_Name,'normal','-','1')%>

Code:
sub {
my $action = $_[0];
if ($action eq "lower") { return lc($_[1]); }
elsif ($action eq "upper") { return uc($_[1]); }
elsif ($action eq "ucfirst") { return ucfirst($_[1]); }
else { return "Invalid action passed..."; }
}

But, that does not function.

Do You think that it is possible?

Thanks again!

Mick
Quote Reply
Re: [MJ_] Ideas please In reply to
Hi,

With the other global, what exactly are you trying to do? You can't pass in global names into a plugin (or a global name, into another global name)

You probably want something more like:

Code:
<%set Full_Name_New = upper_or_lower('lower',$Full_Name,'normal','-','1')%>
<%Plugins::ULTRAGlobals::Edit_Title_Full_Name($Full_Name_New)%>

...or similar

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] Ideas please In reply to
It is exactly what I want to obtain!

Thanks for your invaluable help! :)

Mick
Quote Reply
Re: [Andy] Ideas please In reply to
Hi Andy,

I modified Get_Links_Categories to use the value of build_index_include.

Code:
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . ($CFG->{build_index_include} ? $CFG->{build_index} : '');

Does That function, but do you think that it is correct?

Thanks!

Mick
Quote Reply
Re: [MJ_] Ideas please In reply to
MJ_ wrote:
Hi Andy,

I modified Get_Links_Categories to use the value of build_index_include.

Code:
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . ($CFG->{build_index_include} ? $CFG->{build_index} : '');

Does That function, but do you think that it is correct?

Thanks!

Mick

Looks fine to me :) I need to have a look at adding that kinda stuff in to the plugin at some point, so it takes that into consideration when making category URL's

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] Ideas please In reply to
Hi Andy,

I would like to use the Commify function.

But, that it would be the good value for Column Type ?

I tried to use INT in include_form, but 250.000 gives 250 in database.

I use INT to make a search on the price (&price-ge=100&price-le=1000).

Thanks for your suggestion. :)

Mick

Last edited by:

MJ_: Aug 29, 2011, 5:43 AM
Quote Reply
Re: [MJ_] Ideas please In reply to
Oups ! My approach is not correct!
Iwill use Commify only on the pages of confirmation (success).

Mick

Last edited by:

MJ_: Aug 29, 2011, 5:49 AM
Quote Reply
Re: [MJ_] Ideas please In reply to
Hi,

You would need an INT for whole number, of FLOAT if you want to use decimals. Commify just uses a text string (so it could even be a CHAR), but the problem with that is that you can not do numerical searching ( -lt -gt etc ) with a CHAR field (it needs to be INT or FLOAT, depending on what kinda data its going to be used to store)

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] Ideas please In reply to
For the decimal (FLOAT), could the separator be the dot (.) or the comma (,) ?

Thanks again ! :)

Mick

> > > >