I just recently have created a new module.
Basically what this would do is display in a block latest postings on a particular taxonomy.
There're lot of things need to be done:
1. put more link
2. select what node types to display on the block
3. include related terms and synonyms on that block
here's the code, feel free to test and comment on it. thanks...
[%
function taxonomy_block_link($type, $node = 0, $main = 0) {
if ($type == "system") {
drupal_set_html_head("
rel=\"stylesheet\"
href=\"modules/taxonomy_block/taxonomy_block.css\" />\n"
);
}
}
function taxonomy_block_help($section = "admin/help#taxonomy_block") {
$output = "";
switch ($section) {
case 'admin/help#taxonomy_block':
$output = "
Display list items from taxonomy in a block.
";
break;
case 'admin/system/modules#description':
$output = t("Display in a block the list of items/nodes from taxonomy.");
break;
}
return $output;
}
function taxonomy_block_block($op = "list", $delta = 0) {
if ($op == "list") {
$vocabularies = taxonomy_get_vocabularies();
$ctr = 0;
foreach ($vocabularies as $vocabulary) {
if (variable_get("taxonomy_block_show_" . $vocabulary->vid, 0)) {
$vocab_tree = taxonomy_get_tree($vocabulary->vid, 0);
foreach ($vocab_tree as $term) {
if (($term->parents[0] == 0)) {
$blocks[$term->tid]["info"] = t($vocabulary->name.": ". $term->name);
$ctr++;
}
}
}
}
}
elseif (user_access("access content")) {
$taxonomy->str_tids = check_query($delta);
$term = taxonomy_get_term($delta);
$tree = taxonomy_get_tree($term->vid, $delta);
if (is_array($tree)) {
foreach ($tree as $t) {
$taxonomy->str_tids .= check_query(",".$t->tid);
}
}
$taxonomy->operator = "or";
$taxonomy->tids = explode(",", $taxonomy->str_tids);
$result = taxonomy_select_nodes($taxonomy, 0);
$output = array();
while ($node = db_fetch_object($result)) {
$nodeterms = (taxonomy_node_get_terms($node->nid));
/*
* TODO
* get related terms and synonyms
*/
if (is_array($nodeterms)) {
foreach ($nodeterms as $t) {
if ($t->tid != $delta) {
$temp[] = l($t->name, "taxonomy/page/or/$t->tid");
}
}
}
$terms = $temp;
$temp = array();
$output[] = ($terms ? "".
theme("links", ", ", $terms).": " : "").
l("$node->title", "node/view/$node->nid");
}
if (!empty($output)) {
$content .= theme("block_list", $output);
$blocks["subject"] = t($term->name);
$blocks["content"] = $content;
}
/*
* TODO
* ?create "more" link
* ?points to the taxonomy page of the first level or
* ?points to the taxonomy page plus its children
* ?or points to article module
*/
//$blocks['content'] .= "
l(t("more"),"taxonomy/page/or/$taxonomy->str_tids",
array("title" => t("Read more $term->name items."))) ."
";
}
return $blocks;
}
function taxonomy_block_settings() {
$output = "
can be displayed as a block
(see block configuration)
and list all the nodes under it including nodes of the child taxonomy.";
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$output .= form_checkbox(t("Create blocks for terms of '%vocab'",
array("%vocab" => t($vocabulary->name))),
"taxonomy_block_show_" . $vocabulary->vid, 1,
variable_get("taxonomy_block_show_" . $vocabulary->vid, 0));
}
return $output;
} // taxonomy_block_settings
function theme_block_list($items = array()) {
$output = "
- ";
- ".$item."
foreach ($items as $item) {
$output .= "
";
}
$output .= "
";
return $output;
}
%]
Comments
What name are you giving this module ?
What name are you going to give this module ?
I named my file node_block.module
http://diarist.com - http://computingnews.com - http://scriptdiary.com - http://01wholesale.com - http://businessletters.com - http://businessletter.com
parse error on line 3
Hi,
I'm getting a parse error on line 3.
What might be causing this? Something I'm doing wrong?
E
Module filename
well, I used taxonomy_block.module as the file name.
jhefmv [at] gmail [dot] com
Work smarter, not harder!
no description
I could see the module inside of the module browser at
Home » administer » configuration » module
But there is no description of the module.
It was also invisible inside the permissions.
http://diarist.com - http://computingnews.com - http://scriptdiary.com - http://01wholesale.com - http://businessletters.com - http://businessletter.com
Module description
Descriprion >> Can you please recheck this. I am using this module on my three(3) other sites and it works fine.
invisible on permissions >> Do you mean user permissions? It uses only the "access content" permission.
Thanks
jhefmv [at] gmail [dot] com
Work smarter, not harder!
Worse...
Hi,
I tried to install this also (Drupal 4.4.2), but in my case I can enable the module in the modules section, but after that no sign of it in the blocks section.
What is supposed to happen? Could you give me some more information?
TNX in advance.
Grtz. Henk
WebSite powered by Drupal: http://pd5dp.ham-radio.ch
Other WebSite : http://www.qsl.net/pd5dp
Email:
pd5dp@amsat.org
installing on 4.4.2
Hi,
I'm also trying to install this module on Drupal 4.4.2, but always get a parse error on line 4.
Also no description or block visible in blocks configuration.
What is likely to be causing this parse error? - I would really, really like to get this block to work. I think it is just what I need!
Cheers,
E
Parse error
I can't see why you gusy are having these error. Can you please post what exactly the error is and I will attend to it immidiately.
Thanks,
jhefmv [at] gmail [dot] com
Work smarter, not harder!
parse error on line 4
Hello,
I've added the .css file but still get the error in admin/modules:
Parse error: parse error in /../drupal-4.4.2/modules/taxonomy_block/taxonomy_block.module on line 4
Could it be my copying and pasting the code that is the problem?
This is all a bit new to me..
E
Parse error solution
You can follow the instructions on this post http://drupal.org/node/10710#comment-16494
I hope this would fix your problem.
jhefmv [at] gmail [dot] com
Work smarter, not harder!
parse error on line 4
Hello,
I've added the .css file but still get the error in admin/modules:
Parse error: parse error in /../drupal-4.4.2/modules/taxonomy_block/taxonomy_block.module on line 4
Could it be my copying and pasting the code that is the problem?
This is all a bit new to me..
E
parse error on line 4
Hello,
I've added the .css file but still get the error in admin/modules:
Parse error: parse error in /../drupal-4.4.2/modules/taxonomy_block/taxonomy_block.module on line 4
Could it be my copying and pasting the code that is the problem?
E
parse error on line 4
Hello,
I've added the .css file but still get the error in admin/modules:
Parse error: parse error in /../drupal-4.4.2/modules/taxonomy_block/taxonomy_block.module on line 4
Could it be my copying and pasting the code that is the problem?
E
ps sorry about multiple posting - having real problems accessing drupal.org today - might be firewall problems my end etc..
Set the blocks
After you have enable the module, go to admin/system/modules/taxonomy_block (if you use this name), then check which vocabulary you want to have blocks.
Like any other blocks, you have to set these taxonomy blocks in the admin/system/blocks page. Check those terms you want to appear as block.
jhefmv [at] gmail [dot] com
Work smarter, not harder!
CSS
I forgot to include the css, copy the following classes and save it as taxonomy_block.css in the /modules/taxonomy_block directory.
.block .taxonomy {
font-weight: normal;
font-variant: small-caps;
font-style: oblique;
}
.block .taxonomy a {
font-weight: normal;
}
jhefmv [at] gmail [dot] com
Work smarter, not harder!
It works...
Hi,
I do not know if the CSS file was the cause of not working here, but it works now. It works fine. Consider this a usefull module. Maybe wurth to add to the list of modules here on the Drupal WebSite. I hope you make upgrades and develop this module further.
Also documentation must be created. :-)
Grtz. Henk
WebSite powered by Drupal: http://pd5dp.ham-radio.ch
Other WebSite : http://www.qsl.net/pd5dp
Email:
pd5dp@amsat.org
Parse error solution
Thanks to pss0ft for informing that the missing css file causes this error.
I will be continuing to upgrade this upon the release of the 4.5 version. Further enhancements will be made as I recieved any helpful suggestions and comments.
Here's a brief installation instructions:
Installation
------------
This module requires no modification to the Drupal database.
Copy php code above and save it as taxonomy_block.module
Copy the styles above and save it as taxonomy_block.css files
Move the two files to the Drupal modules/taxonomy_block directory.
Go to "modules" under "site configuration" in the administration pages and enable the module.
Check the "settings" page and set the module settings to your liking.
Go to "blocks" under "site configuration" and tick the box besides the term you want to appear as a block.
Name: taxonomy_block module
Author: Jhef M. Vicedo
Email: jeff at digitalsolutions dot ph
Thanks,
jhefmv [at] gmail [dot] com
Work smarter, not harder!
Yes...
Hi,
The above points was exactly what I did to get it installed and as stated before in another posting of mine: it works!
I look forward to any enhancement.
Grtz. Henk
WebSite powered by Drupal: http://pd5dp.ham-radio.ch
Other WebSite : http://www.qsl.net/pd5dp
Email:
pd5dp@amsat.org
do you have an example of thi
do you have an example of this working ?
http://diarist.com - http://computingnews.com - http://scriptdiary.com - http://01wholesale.com - http://businessletters.com - http://businessletter.com
Yes...
Hi,
It works on my website. Rightside. Forumspostings is a example of a block created by this module.
http://pd5dp.ham-radio.ch
Grtz. Henk
WebSite powered by Drupal: http://pd5dp.ham-radio.ch
Other WebSite : http://www.qsl.net/pd5dp
Email:
pd5dp@amsat.org
Another site
You can go to this site TruthForce! and all the blocks on the right side are created by this module.
jhefmv [at] gmail [dot] com
Work smarter, not harder!
not working in 4.5
has anybody got this working with drupal 4.5? I can see the administer -> module list. But after enabling, i dont see it anywhere else? I dont see it in administer -> settings or blocks.
thanks,
Paul
haven't ported this yet
Actually I have 4.5 compatible version but haven't upload it yet here 'coz I don't have cvs account.. Email me if you want a copy
Work smarter, not harder!
jeff@digitalsolutions.ph
jhefmv [at] gmail [dot] com
Work smarter, not harder!
Taxonomy_Block 4.5
try this: http://drupal.org/node/15192
Work smarter, not harder!
jhefmv [at] gmail [dot] com
Work smarter, not harder!