Indizar – Plugin para WordPress
El tag de WordPress para ‘paginar’ ofrece una buena opción para dividir un documento largo en diferentes páginas, pero aveces necesito dividir un documento por capítulos y no por páginas, junto con un índice que facilite la navegación por el documento por medio de los títulos de los capítulos, y no solo por el número de página.
En particular esa situación la viví al publicar sobre la trilogía Qatsi. Dividí el documento en capítulos por cada filme, y agregué un capítulo de introducción. Al ver la publicación en línea terminé con la sensación de que estaba perdiendo continuidad la página y el usuario no entendería por qué hacía esa separación, aun cuando los títulos al inicio de cada página explicaran un poco las razones. Viendo esa situación programé una solución propia.
Así nace Indizar, un plugin que permite agregar capítulos en las entradas y definir un listado de capítulos como si se tratara de un índice de contenido.
Para agregar un capítulo se debe usar [chapter:titulo del capítulo] al inicio de cada sección. Por defecto el primer capítulo llevará el nombre del post, y la primera aparición de [chapter:***] será identificada como el segundo capítulo. Si desea asignar otro nombre al primer capítulo podrá usar [firstchapter:***] para así indicarle al plugin que use este nombre en vez del título del post, sin que se genere una nueva sección que inicie desde esta etiqueta, pero publicando este título con las mismas características de los títulos iniciales en los capítulos.
Para agregar el índice se puede usar [chapters], para un listado con valores por defecto, o [chapters:ancho,(left|right)] para determinar el ancho de la caja, y de qué lado deberá ir en el texto general. El primer capítulo será por defecto el nombre del artículo, o el título identificado en ‘firstchapter’ si se creó la etiqueta. Las cajas del índice se presentan cuando se está visualizando la página del artículo, en los restantes casos -búsqueda, índice, tags, etc- no aparecen. Al final de cada capítulo habrá un listado similar a la lista de páginas que publica wordpress cuando se emplean las etiquetas nextpage.
Para definir la configuración se emplea la etiqueta [indizar:#conf,tamaño_caja,posición_caja,título_prefacio] con la siguiente definición de variables:
- #conf: un número que define algunos elementos de la indización.
- 0- Sin lista numerada.
- 1- Lista numerada en la parte superior.
- 2- Lista numerada en la parte inferior.
- 3- Lista numerada en ambas secciones
- tamaño_caja: tamaño de la caja de índice que se pondrá después de cada título de capítulo.
- posición_caja: posición de la caja. Puede ser ‘left’ o ‘right’ para ponerla del lado izquierdo o derecho después de cada título, si es ‘none’ no se pondrán cajas después de los títulos y se deberán declarar manualmente con las etiquetas [chapters].
- título_prefacio: variable opcional. En caso de declararse, la numeración iniciará en 0 y la lista numerada visualizará el capítulo inicial con el nombre definido en esta variable, en vez de ser visualizado con un 0. Si no se define esta variable la numeración se iniciará en 1 y en la lista numerada el primer capítulo se representará con un 1.
Desde la versión 0.5.1 se puede definir una configuración por defecto en el archivo wp-config.php para que las páginas separadas con caracteres tengan un comportamiento homogéneo. La configuración permite definir si habrá listado numerado arriba y/o abajo, si habrá caja de capítulos después de cada título, tamaño y posición, y si se usará un prefacio y el título del prefacio en la lista numerada. La siguiente es la lista de definicones por defecto:
define(‘INDIZAR_TOP’, false);
define(‘INDIZAR_BOTTOM’, true);
define(‘INDIZAR_BOX’, true);
define(‘INDIZAR_BOX_SIZE’, 200);
define(‘INDIZAR_BOX_FLOAT’, ‘right’);
define(‘INDIZAR_USE_PREFACE’, false);
define(‘INDIZAR_PREFACE_TITLE’, ‘Prefacio’);
Cuando se definen esta variables tan solo será necesario escribir las etiquetas chapter y firstchapter, porque el plugin formateará el post según las definiciones, publicando las cajas de capítulos después de cada título, y al inicio del post en caso de no haberse definido un firstchapter. En caso de haber una etiqueta chapters el plugin publicará la caja en esa posición en vez de seguir la recomendación por defecto.
Para facilidad al momento de agregar capítulos, índices y configuración, se ha agregado un botón en el editor gráfico.
Estas etiquetas no se deben usar en un mismo post junto con ‘nextpage’.
Para los que les gusta programar en los templates existe la función chap_list() que retorna false si no hay lista de capítulos, o la lista si existe una. Esta función se debe usar después de llamar la función the_post().
La instalación del plugin requiere dos pasos extra:
- Agregar una línea de código en /wp-includes/query.php
if(function_exists('ind_prepost')) $content = ind_prepost($post);Esta línea se debe agregar en la funcion ‘setup_postdata($post)’ después de ‘$content = $post->post_content;’
- Agregar los elementos del CSS a su lista de estilos, si lo desea, y modificarlo
Estoy buscando la forma de evitar tener que hacer las modificaciones al código de WordPress.
Importante: si emplea permalinks deberá volver a crear el caché de reglas para que identifique la etiqueta ‘chapter’ en los URL de la página. Vaya a Opciones -> Permalinks y seleccione ‘Guardar Cambios’.
A partir de la versión 0.4 el motor de Indizar agrega sus propias reglas a los permalinks, así que ya no es necesario hacer las modificaciones que en versiones anteriores se hacían en el archivo ‘query.php’ ni agregar manualmente el archivo css para los estilos. Si ya había hecho el cambio deberá eliminarlos manualmente.
Para ver un ejemplo, puede leer el informe sobre el viaje al parque de los nevados.
El plugin está bajo licencia GPL para que lo usen, abusen y descuarticen, solo recuerden dar los créditos del caso.
Ir a la página de descarga.
Internacionalización
- Ruso por Дн, un abogado que le gusta poner a punto su página personal.
- Polaco por Bartosz Kowa.
Muchas gracias por su tiempo amigos.
Características
- Divide un post en capítulos, y permite definir posiciones para cajas con el índice.
- Indizar está disponible en el servidor SVN de WordPress.
- Permite previsualizar entradas divididas en capítulos que aun no se han almacenado.
- Mecanismo para primer capítulo.
- Mecanismo para definir configuración:
- Listado numérico al inicio y/o al fin.
- Caja de capítulos después de todos los títulos de capítulos.
- Usar prefacio para que la primera página quede fuera de la numeración y pueda declarar la segunda página como el p[rimer capítulo, quedando reflejado ese número en la URL.
- Mecanismo para definición de caonfiguración por defecto en wp-config.php. Ver readme.txt para un ejemplo por defecto.
- Motor de capítulos propio. No emplea <!–nextpage–>
- Archivo de CSS propio.
- Número de capítulo a visualizar es detectable desde el permalink. Importante: Deberá volver a crear el caché de reglas para poder usar este plugin. Vaya a Opciones → Permalinks y seleccione Guardar Cambios. Con esto se agregará la etiqueta chapter a las reglas de permalink de la página.
- Administrador funcional en WordPress 2.7
- La función chap_list() retorna arreglo con título y url.










I’m implementing this and I have two issues I can’t work out.
First, clicking on the button in the visual editor gives an internal server error [removed .htaccess, checked folder permissions, still doesn't fix it]
Also, I can use [chapters] to display and index; however using [chapters: 200, right] will not format the index listing. Instead it prints [chapters: 200, right]
Any suggestions for troubleshooting?
Hello and thanks for using Indizar.
I’m not sure if i’m understanding this bug. Would you please send a snapshot of the problem? And about the tag, don’t use spaces in it [chapter:200,right]
Hi.
Page numbers in the lower index starts from one. Tell me, please, what should be changed so that they start from zero?
And Indizar is compatible with version 2.8.5?
Hi.
I’m using Indizar in 2.8.5 and it works ok.
To change the numbers in the footer, look inside the function ind_content.
Compatibility with 2.8.5 – it’s good.
ind_content changes number of start page. But I need to change the order of numbering.
Now pages are numbered as 1,2,3,4…
I would like to do as 0,1,2,3…
A new version is comming. Look your email to beta test this new release.
Thanks.
New release. Try the new tag to define the preface.
Thanks for the great plugin! I am wondering, how to I get the chapter list to appear at the top of each post too? I have been just copying the html that your plugin generates and pasting it in the post. Thanks!
Thanks for using indizar.
I can create a special tag for this, but I need an example. Are you talking about the numbered list at the end of each page?
Thank you for the reply. Yes I am talking about the ‘Chapters: « Previous 1 2 3 4″ that get generated at the end of the chapter. To increase usability I would I also like to include this at the beginning at the chapter. A new tag would would be convenient and appreciated. As a work around for now, is there some PHP code i could use to have the same effect?
Thanks.
New release. Try the new tag to use the numeric list at the begin.
The new release (0.5.1) has something you would like. Take a look to the readme.txt about the default configuration in wp-config.php
I’m using your Worpress plugin “Indizar” in my personal blog (currently using WP 2.8.6.). I think it’s really great and it helps me structuring my tutorials I publish there.
Today I encoutered a little problem with your plugin. On those pages, where multiple blog posts are shown (by category, tags, etc.) but not at the page actually showing the blog post itself, I got the following PHP warning:
Warning: Invalid argument supplied for foreach() in /wp-content/plugins/indizar/indizar.php on line 650
And the indizar tags had not been removed from the text.
I don’t really know if this bug was introduced in version 0.5.3.1 or earlier. Perhaps I just didn’t recognize it. Nevertheless I had a gance at the code and did a quick fix:
— old/indizar.php 2009-12-19 15:31:00.000000000 +0100
+++ new/indizar.php 2009-12-19 15:31:13.000000000 +0100
@@ -645,25 +645,12 @@
function ind_delete_extra_tags($content) {
//Delete the chapters tags, because we don’t need it
$search = “@(?:)*\s*\[chapters\]\s*(?:)*@i”;
- if(preg_match_all($search, $content, $matches)) {
- if(is_array($matches)) {
- foreach ($matches[1] as $key =>$v0) {
- $search = $matches[0][$key];
- $content = str_replace ($search, “”, $content);
- }
- }
- }
+ $content = preg_replace($search, ”, $content);
//Delete the chapters tags, because we don’t need it
$search = “@(?:)*\s*\[chapters\s*:\s*(\d+)(||,left|,right)\]\s*(?:)*@i”;
- if(preg_match_all($search, $content, $matches)) {
- if(is_array($matches)) {
- foreach ($matches[1] as $key =>$v0) {
- $search = $matches[0][$key];
- $content = str_replace ($search, “”, $content);
- }
- }
- }
+ $content = preg_replace($search, ”, $content);
+
return $content;
}
I haven’t had a deeper look at your code, so don’t expect too much, but it seems to work for me.
Christian
I guess, I forgot the pre tags…
— old/indizar.php 2009-12-19 15:31:00.000000000 +0100
+++ new/indizar.php 2009-12-19 15:31:13.000000000 +0100
@@ -645,25 +645,12 @@
function ind_delete_extra_tags($content) {
//Delete the chapters tags, because we don’t need it
$search = “@(?:)*\s*\[chapters\]\s*(?:)*@i”;
- if(preg_match_all($search, $content, $matches)) {
- if(is_array($matches)) {
- foreach ($matches[1] as $key =>$v0) {
- $search = $matches[0][$key];
- $content = str_replace ($search, “”, $content);
- }
- }
- }
+ $content = preg_replace($search, ”, $content);
//Delete the chapters tags, because we don’t need it
$search = “@(?:)*\s*\[chapters\s*:\s*(\d+)(||,left|,right)\]\s*(?:)*@i”;
- if(preg_match_all($search, $content, $matches)) {
- if(is_array($matches)) {
- foreach ($matches[1] as $key =>$v0) {
- $search = $matches[0][$key];
- $content = str_replace ($search, “”, $content);
- }
- }
- }
+ $content = preg_replace($search, ”, $content);
+
return $content;
}
Unfortunately pre tags don’t seem to work here. Just send an email, if you are interested in the patch file…
Christian
Hi Christian. Yes, I’m interested in your patch. Send it to this mail (sebaxtian at gawab dot com).
Thanks.
Can I ask you to help me with the i18n Indizar? I want to put a german version in the nex release.
Danke shoon!
The mail is done. You should have received my (tiny) patch.
Translating indizar to German should be no problem, but depends a bit on my time. I’m currently writing my bachelor thesis (and other stuff), so my time is a bit… limited at the moment. But let’s say in mid january maybe end january I will have plenty of time. Just write me an email by that time. I wanted to learn using GNU gettext anyway…
Christian
Unfortunately the problem still exists in version 0.5.4. I’ve just updated. When I look at the code, my changes are not applied. Something has changed, as the line number of the error is now 653 istead of 650, but the critical lines remain untouched. Either you haven’t applied the patch properly or my WP was somewhat confused, because I had applied my change manually beforehand…
Christian
Oops! Error in the change log.
The patch was applied in release 0.6
Thanks for beginning a German translation. German words seem to fit much better in my German blog… *g*
One comment:
Kapitel: | Zurück | 1 | … | n | Nächste |
That doesn’t fit (if you take it exactly).
“Kapitel” is neuter (“das Kapitel”), so it would be “Nächstes”. “Nächste” would be correct, if you’d refer to pages (“Seiten”) instead of chapters (“Kapitel”).
On the other hand “Zurück” would be rather “back” and not “previous”, so it’s not the oppotite of “Nächstes”.
I’d prefer
Kapitel: | Zurück | 1 | … | n | Weiter |
I would say, that’s the way it’s mostly done on German sites…
Christian
Thanks Christian. New release with you correction.
Works fine with WP 2.9.1 too. Although http://wordpress.org/extend/plugins/indizar/ only states “Compatible up to: 2.8.5″.
Christian
Hello, can Indizar work with ajax (or may be jQuery can do it)? Display chapters with nonrefreshing the page.
Understand me? Sorry, my english is bad, hello from Russia
Thank you.
Hi Snpru.
The feature you asked is at the top of the to-do list. Unfortunatelly I’m busy right now to work in this plugin, but maybe in a near future I would add this feature.
Please, add this feature in the near future.
It would be great. Please, find a little time.
In this month can wait?
May be i could contribute?
Is very importantly for me.
My english is bad, sorry again…
I’m curious. Why do you need this feature so madly? And tell me about this site you are developing.
It would look beautiful, i think this will increase usability and functionality, because header is long (logo+flash intro+navigation).
I developing simple site, with catalog, where children pages displays with Indizar.
If it possible, say what changes should be done in current Indizar?
If it is very difficult for you, have to wait.
I’m sorry that takes your time and thank you for Indizar.
Unfortunately there isn’t a simple change to do now. It would requiere to change some parts inside Indizar’ s core system. I would end some work this week and then I would try to find a way to solve this.
And thanks for your suport.
Great! I will wait…
Hi Snpru.
I have found a way to do what you want, but I can’t figure how to apply this fix inside the plugin.
I can create a jQuery script to add at the end of a theme that requires you to define the ‘div id’ that wraps the post. As an example in this page the div has id=post-181, so I will send post-181 as the argument to the script.
I’ll work on this script tonight. Hope I have good news tomorrow.
I will wait your result here, but everything else content on site is not english…
Good news, I have figured how to put it inside Indizar. I will work on it, but give me a week.
¡Feliz tarde!
Nice!
That is “¡Feliz tarde!” ?
Ok, test time. Check if this is the behavior you need in the plugin. I have two more things to do here, but I think we are close to what you need.
Have a nice day.
Oops, I almost forgot. Use this link http://www.sebaxtian.com/archives/180
What two more things?
Great! Where i can download new Indizar?
Loading gif using? I dont see this, if he using.
Check again http://www.sebaxtian.com/archives/180
I will publish the new release when I finish the test, but I will publish it today (here in Colombia is 10 AM).
Any sugestions?
Nice, fade out and fade in is beautiful.
My suggestions: Loading animation.
I’m designing this script so the users can implement it with other links.
The problem with the loading animation is: there are 3 places in indizar where the user can link to another chapter, and I can’t figure where to put the loading animation so the user can see it ven if the user use the links at the begining, in the chapter index, or at the bottom.
Doy you have any idea where to put the loading animation?
May be put loading animation instead of content, then it does not matter where user use the links…
Or instead of links…
In my case, the content would be so big, and I can’t figure where should the loading image be, and copy the loading image all over the content would be annoying.
Other would be to use the same image used with the photo in the right panel. Click on it…. but I prefer the fade effect. I think it is good for what we need.
I have a problem with the ‘share’ plugin. The ‘email’ button doesn’t display correcty. I’ll try to fix it tonight.
I have not any idea
What a share plagin?
I think all good working now, waiting the release.
Loading image just more stereotype than a real need. But makes sense to leave it as is.
When to wait for release?
If place loading animation instead of content, if must placed center, by vertical, imho…
But without animation, as now, looks nice.
It’s ready to download. See the readme to know how to enable the AJAX feature.
Tell me how it goes so far.
Very nice!
Easy to install this feature, and work good.
Thank you!
Great to hear it works. Could you please give me the link to the page where you use indizar?
Link: http://sevcable-omsk.ru/?page_id=553
Another question: can every element place picture?
Example:
Chapter name 1
Chapter name 2
Your site eats tags
Another question: can every -li- element place picture?
Example:
-img1- Chapter name 1
-img2- Chapter name 2
Tags symbol i replaced -.
Hi, I have a problem with the permalinks. If I activate the Indizar the Permalinks doesn’t work anymore. I have already “Options > Permalinks and press the button Save Changes” and the .htacces deleted and recreated. I get always crazy URLs like” wordpress321/beispiel-seite/chapter/%chapter%/”
If I delete the last string **/%chapter%/** from the URL, it is working correct.
Installed System: WordPress 3.2.1
Plungins: Indizar, Mingle Forum, Page Columnist
Do you have any ideas how I can fix this problem?