Looking for self-updating alphabetical list of posts
-
On a separate page on my site, I want to list links to my posts alphabetically indicating post date and tags — and to really be outrageous, the first few lines of the post.
I can do this by hand in a CSS/HTML table every time I post, but would like to use RSS feed if possible, and have it sort itself alphabetically, updating at time of post.
Has any work been done on any part of this? Is there already a plugin that does it? Am I dreaming in technicolour?
-
Given the varied situation (since not all of your posts are poetry, etc..) a word count might indeed be the best method.
As far as the bold text.. that can be fixed by having the function strip out the tags.
Try this (hopefully this will show up properly):
function ddsg_get_contents($i) {
global $ddsg_data;
global $wpdb;
global $table_prefix;$t_word_count = 30; // number of words to show
$the_text = $wpdb->get_var("SELECT post_content FROM " . $table_prefix . "posts WHERE ID=" . $i);
$the_text = strip_tags(trim($the_text));
$t_array = explode(" ", $the_text, $word_count + 1);
$t_output = NULL;
for ($n = 0; $n < $word_count; $n++) {
if ($t_array[$n]) {
$t_output .= $t_array[$n] . " ";
}
}
return "<br />" . $t_output . "<br />";
}In the above code, I have the variable called $t_word_count, but below, I am referencing $word_count.. just change it to $t_word_count too ??
How sweet it is! It woiks!
If you are going to incorporate this enhancement in future versions, I imagine you will want to give users the opportunity to reveal no text or as much as they want.
One feature that we had earlier but do not now is the poetry line divisions. It is standard practice when quoting poetry that does not appear with the original line breaks, to indicate line breaks with the forward slash. I am quite happy to do without, as the plugin really achieves what I was hoping for: a manageable indication of the content.
Thank you, Aleister! I shall put a link to your site in my note about the index.
Glad it works ??
One other thing you could do is wrap the displayed text in quotes, and have a “…” at the end.. or something to that effect, so that it is clearly an excerpt. Or you could use some CSS to make it stand out a bit.. anyway, up to you ??
If you want to add the forward slashes, just append it to the string in the loop. It will, of course, apply it to non-poetry too as well, unless you gave your poetry posts an additional variable to specify them as such, and then the script could look for that variable to determine whether or not to display the slashes, but that would be getting more complex than you might want ??
I may add it to future versions.. It is hard to decide what to add sometimes, because I do get a lot of requests. I add pretty much all of them, but there is a certain point where I have to stop so the options page does not get overloaded, and is not too complicated for people to actually use *grin*
If I do make an option out of it, I would also throw in an option for an excerpt prefix and suffix, so one could add quotes, or some css, etc.. around the text.
Who knows.. I may ??
I really like those tweaks you are suggesting.
I awoke this morning with the thought that you could specify use of the category “poetry” or more precisely, “verse” as a condition for adding ‘ / ‘ at the end of each line.
Anyway, it is a neat plugin that has dipped my feet into php.
Thanks.
Good idea.. checking the category would be much easier, as it would not require any extra calls to the database.
I will see what I can do ??
Ok, I just uploaded a new version for you. Be sure to use the whole file, since I updated more than the ddsg_get_contents function (the way it pulls the data is a bit different).
Here are the options you need to set:
$t_word_count = 10;
This is the number of words that will be shown for non-poem posts.
$t_line_count = 3;
This is the number of lines show for poems
$t_eol_poems = "n";
This is what the script looks for, to determine the end of a line in a poem. This setting may depend on how you are doing the breaks.
$t_prefix = '<br /><span style="font-size:120%;color:#888888;">“ </span>';
This is the prefix for each excerpt. This example adds a break, then a fancy left double quote (styled a bit).
$t_suffix = '...<span style="font-size:120%;color:#888888;"> ”</span><br />';
This is the suffic for each exterpt. It shows the ‘…’ and the closing fancy double quotes.
$t_break_cats = Array('Poems');
This is an array of the categories that will be treated like poetry (X lines shown with the slash at the end).
Hope it works for you ??
I was worried that would happen ??
$t_eol_poems should have a backslash before the ‘n’ ??
(And please ignore the mispelled words.. I was rushing ?? )
After I typed this, I came to realize that maybe you should just skip to the final paragraph, then if you want to, you can read the rest to see the rationale.
I have the new code up, and it certainly makes me rethink the premises of my original “outrageous” request. I see now that using all the categories complicates the problems immensely if we are trying to distinguish between poetry and prose; for example, a poem is categorized as creative writing, so when it is listed under creative writing, along with , say an essay, which is also creative writing, they both come off as prose, and we have no way to differentiate. I think that differentiation in that case is actually too complicated.
Another issue is that when the poetry category or any category listed in the array for slashes etc come up, the depiction in the final result comes out with the line-breaks in, so that the slash is not needed. To clarify: here is poetry correctly quoted with line breaks:
blah blah blah,
blah blah blah,
blah blah blah. . . no quotation marks, no slashes needed.here is poetry correctly quoted without line breaks: “blah blah blah, / blah blah blah, / blah blah blah . . .” the slashes show the line breaks, which are needed because the line breaks are significant in poetry, unlike prose.
This is sort of like the use of the apostrophe. So many people misuse it that it is safer not to use it than to use it.
Conclusion: I really like the control over the number of words in prose that comes off really well. I like the way the actual poetry categories can be set to show the line breaks; I think if all entries showed line breaks, not just poetry, that would solve everything, and the slashes would not be needed. All one would have to do to make it work reasonably would be to reach a reasonable compromise between number of words and amount of poetry and prose one wants to show. So: no slashes, yes line breaks, yes word count. Does that make sense?
You are making this difficult.. j/k ??
Well when the script shows the data based on the number of words, line breaks are not kept in tact the way they are with the line count method. That is why it is tricker to do both.
You could try this..
Clear the array for the cats which will use slashes and count by lines (easier then removing the code for that functionality right now):
$t_break_cats = Array('');
Then change this line (at the bottom of the ddsg_get_content function):
return $t_output;
to this:
return nl2br($t_output);
And _hopefully_ it should keep the breaks in place by transforming them into useable ones while still counting the words. ??
and the result is:
Fatal error: Call to undefined function: n12br() in /home/riverwri/public_html/wordcurrents/wp-content/plugins/dd-sitemap-gen5.php on line 671ulp! ??
I’ll change that line back and see what it looks like with the Array empty.
Fortunately, I have kept every revision with a slightly different filename. What we have posted now is the result of posting with a blank Array. It serves the purpose. We can tweak this until the cows come home, and I certainly appreciate all the work you are putting into this, but surely you have a life and I am starting to feel as if I am condemning you to push this giant rock uphill eternally . . . ??
BTW: I really like the addition of the elipses and the curly quotes.
??
I am not sure if that latest code change will even help much, but for the record – nl2br (that is NL not N1 ??
Wow!
Aside from the second entry “Guess who?” (the Star Trek survey results), which looks a little extended, the rest looks very much the way I envisioned in my original “outrageous” request. I think I will tinker with the prose word length a bit, and that’s it.
Excellent. Brilliant as the Brits say.
Thank you.I note that there is a certain variation in the number of poetry lines coming up. I wonder that may have something to do with the form of the line breaks I am using; or it might be related to the “more” code I placed in the more recent articles. I have the number of prose words set to 15 and the number of lines of poetry set to 3, in the version being used on the site at present. It still looks pretty good the way it is. ??
- The topic ‘Looking for self-updating alphabetical list of posts’ is closed to new replies.