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

Fields from the first post at the nth page of a category

Quote Reply
Fields from the first post at the nth page of a category
I just play around with lsql as a news-blog without any detailed pages.
I make a new page every 25 links.
Now i want to have the title of the first link as the title of the page.

So i should have something like:

call a new global and pass the number of page (maybe there is a global for as i remember)
calculate: number of page = 1, then x = (nop -1) * 25 + 1 = 1
number of page = 2, then x = 26
number of page = 3, then x = 51

Now fetch the title of the 51th link and set it to html title.

SELECT * FROM Links ORDER BY some LIMIT 1 OFFSET 50;
Quote Reply
Re: [Robert] Fields from the first post at the nth page of a category In reply to
Hi,

Wrong forum :) (you posted in the GForum one). I've moved it for you.

I'm not really sure what you are asking for?

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] Fields from the first post at the nth page of a category In reply to
Is there a global for the number of page of category pages?

I want to set the html.title and html.description with data from the first link that is shown on a page:

1. Red cars in Cleveland
2. Green cars in Detroit
....
25.

Then red cars should be set for the html.title of the page in header.

26. Yellow Cabs
27. Lalal
...
50
Yello Cabs should be used

So i need a global to fetch the data from the first link inside a category page.
For this i should know the page number. Then i can calculate and fetch the right link, right?
Quote Reply
Re: [Robert] Fields from the first post at the nth page of a category In reply to
Code:
<html><head>
<title><%globalx(page number)%></title>
</head>
....
</html>




x = pagenumber form call this global

y = (x -1) * 25 + 1

SELECT * FROM Links ORDER BY some LIMIT 1 OFFSET y-1;

Last edited by:

Robert: Jul 19, 2016, 11:07 AM
Quote Reply
Re: [Robert] Fields from the first post at the nth page of a category In reply to
Hi,

Assuming I understand you right: You are doing this on a category page, and just want to get a value from the first link in that category? If so, you don't need to do any extra queries. Just use:

Code:
<%links_loop.0.ID%>

Replace "ID" with whatever column you want to get :)

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] Fields from the first post at the nth page of a category In reply to
Wow!
It seems you are the real heat of LSQL!
Thank you again and again and again.

What do you think about LSQL 4.0 completely rewritten by yourself?

BTW: Do you have an idea, how we could make LSQL more dynamic?
I love to have builded pages, but it is normally not possible to filter things inside the category_pages.

I always save them as .php to have more possibilites, but i still need own pages, if i want to show filtered things like "show only paid links" e.g.

Probably i should use javascript to write the data of my "Links" to arrays and show them dynamically.
https://datatables.net/examples/api/show_hide.html

not possible for more than 1 cat_pages, shure.
Quote Reply
Re: [Robert] Fields from the first post at the nth page of a category In reply to
Hi Robert,

I would expect

<%if links_loop.0%>
<%links_loop.0.Title%>
<%else%>
Title if there is no link on the page
<%endif%>

to work, not tested, but I guess this

Cheers

n||i||k||o
Quote Reply
Re: [el noe] Fields from the first post at the nth page of a category In reply to
OK, sorry just saw the first two posts, whatever happened there Angelic
Quote Reply
Re: [Robert] Fields from the first post at the nth page of a category In reply to
haha no problem Angelic

Quote:
What do you think about LSQL 4.0 completely rewritten by yourself?

LOL ... not sure GT would let me do that ;) (or that I would have the time)

Quote:
BTW: Do you have an idea, how we could make LSQL more dynamic?
I love to have builded pages, but it is normally not possible to filter things inside the category_pages.

I do all of my sites using mod_rewrite, and page.cgi. If you want to add sorting filters, its a bit trickier. The easiest way I've found, is to set a cookie when they change a setting - and then on reload, check if that cookie has a value. So say you had "customSort" as a cookie... you could do something like this in /Links/Build.pm:

Code:
$opts->{sb} = exists $opts->{sb} ? $opts->{sb} : $CFG->{build_sort_order_category};

,..add something like this after:

Code:
if ($IN->cookie("customSort") =~ /^(foo|bar|something)$/) {
$opts->{sb} = $IN->cookie("customSort")
}

Obviously its not ideal (as it means you need to edit the core codes) ... but it works :)

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!