Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-11-08 17:12:41

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

[es-es] Crear un índice alfabético (A-Z)

Estimados
Necesito crear un índice A-Z donde se muestre un listado de artícules ordenados alfabeticamente.
Me gustaría que me den una idea como puedo resolver este desafio donde el usuario al clickear una de las letras

A – B – C – D – E – F – G – H – I – J – K – L – M – N – Ñ – O – P – Q – R – S – T – U – V – W – X – Y – Z

aparezcan los articulos que corresponden a esa letra.
Aguardo sus comentarios.
Un saludo y gracias

Offline

#2 2013-11-08 19:19:08

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: [es-es] Crear un índice alfabético (A-Z)

Pardon my Spanish:

<txp:etc_query
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 ORDER BY alpha ASC"
	query="//alpha[strcmp(string(text()), '{?alpha|A}') >= 0]" globals="_GET" functions="strcmp" limit="1"
>

	<!-- Navigation list -->
	<ul>
	{../preceding-sibling::row/alpha&=<li><a href='?alpha={?}'>{?}</a></li>}
	{.&=<li class="active">{?}</li>}
	{../following-sibling::row/alpha&=<li><a href='?alpha={?}'>{?}</a></li>}
	</ul>

	<!-- articles output -->
	<txp:etc_query name="ids" break=","
		data="SELECT ID FROM textpattern WHERE UPPER(SUBSTRING(Title,1,1)) = '{?}' AND Status = 4 ORDER BY Title" />

	<txp:article_custom id='<txp:variable name="ids" />' limit="999" />
</txp:etc_query>

Last edited by etc (2013-11-08 20:59:15)

Offline

#3 2013-11-08 20:15:23

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: [es-es] Crear un índice alfabético (A-Z)

Excellent Oleg!
In my first try, it worked like a charm.
Thanks for your code and your excellent plugin.
Best regards from Argentina
Fernando

Offline

#4 2013-11-08 21:05:05

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: [es-es] Crear un índice alfabético (A-Z)

Glad you like it, pin Argentina flag on my etc_query map. :)

You are right, the first version was multi-byte safer, corrected now.

Edit: I’ve made a paginated version, with demo.

Last edited by etc (2013-11-09 20:10:27)

Offline

Board footer

Powered by FluxBB