This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Flexinode: How to make a certain field not render except in teaser?

The pertinent lines of code seem to be Line 675 of flexinode.module, and Line 65 of field_textarea.inc

Logically, it seems that I could make it negate the output of content if $field->field_type was a specific number, but I have no idea how to edit to code to accomplish this, since the way the code seems to work is that it immediately inputs all fields, and there seems no easy way to change this.

( Line 686: $node->body .= theme('flexinode_'. $field->field_type, $field->field_id, $field->nullity, $node->$fieldname, $data); )

front.module for 4.5 release

I have been trying the front.module to have a static front page. All I receive is a page not found. I believe the reason is because the module has not been upgraded.

I have tried to make sense of the module development guide, but have no clue.

Could someone help upgrade this module for 4.5

Sort content using the Node Moderation module?

Anyone know if it's possible to sort content published to the front page using the ratings of the node moderation module? I want the content on the front page sorted from best rating to worst.

node privacy by.... can we have user?

Hi... I was looking at the nodeprivacybyrole module, and it's pretty cool and really useful.

Is there any node privacy by [b]user[/b] module in work or in plan?

Footnotes module - a proposed solution

There is an old problem in Drupal, which is that when you copy/paste text containing references to within the page, then because of the way Drupal handles the URLs, if you click on the references you get sent to the front page, instead of getting sent to the reference in the same page.
I find this particularly annoying because the site I am developing will take content (articles) copy/pasted from Word or OpenOffice (Word/XP now does a particularly nice job of converting superscripted footnote references into something easily readable on the web when you copy/paste), and these articles very often have footnotes generated by the Word or OpenOffice.

I wrote this module (for 4.5.0) to handle the problem - but feel a bit intimidated submitting it to CVS because a) there are clearly lots of people who are far better than me at doing this kind of thing and b) I can't guarantee to maintain it, plus c) although it seems to work for me there may be other cases I've not taken into account.

What does the module do?
Basically, it works with page, story, or book type nodes, searches the node body for any occurrences of href=#xxx (or href=yyy#xxx) and replaces these with href=pathalias#xxx. Occurrences of href=#xxx are stripped out of the teaser (don't want them to appear here and anyway they could lead to confusion). In all other node types, it just strips the notes out altogether (this of course is fine for my purposes but not necessarily very generic).

In order for the module to work, you have to have the "path" module enabled, and enter a "Path alias" for the content. You can't just use the node number, because when you are in the process of creating a node, the node number is not yet known. Consequently, you can't use it (logical!!).

Anyway, here is the code. Any comments would be very welcome - otherwise feel free to use and I hope this is helpful:

// $Id: node_footnotes.module,v 0.1 2004/10/20 Joel Guesclin $

/**
 * @file
 * Resolves the problem of dead footnotes (eg bottom of page notes) as
 * generated by Word or OpenOffice
 */


/**
 * Implementation of hook_help().
 */
function node_footnotes_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Converts footnote references to include node reference');
  }
}

/**
 * Implementation of hook_nodeapi().
 */

function node_footnotes_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'validate':
      if ($node->type == 'page' || $node->type == 'story' || $node->type == 'book') {
         if ($node->title) {
// Here is the original regular expression to get all anchors out of a chunk of HTML:
// '/<a(\s)+[^>]*href(\s)*=(\s)*(\'|")*[^"\'>]+(\'|")*[^>]*(\s)*>(.|\s)*?<\/a(\s)*>/i'
// Thankyou Sam Fullman at codewalkers.com for a sweet piece of coding!!!
// And then, we add the hash in order to find only the footnote type href's
             $findMatches = preg_match_all
('/(<a(\s)+[^>]*href(\s)*=(\s)*(\'|")*)([^"\'>]*)#+([^"\'>]+(\'|")*[^>]*(\s)*>(.|\s)*?<\/a(\s)*>)/i',
$node->body,$matches); // "
             if($findMatches){
                if (empty($node->path)) {
                   form_set_error('path', t('You must supply a path.'));
                   break;
                   }
                $string = $node->body;
                $pattern = '/(<a(\s)+[^>]*href(\s)*=(\s)*(\'|")*)([^"\'>]*)#+([^"\'>]+(\'|")*[^>]*(\s)*>(.|\s)*?<\/a(\s)*>)/i'; // "
                $replacement = '\\1'.$node->path.'#\\7';
                $node->body = preg_replace($pattern, $replacement, $string);
                if ($node->teaser) {
                   $string = $node->teaser;
                   $replacement = '';
                   $node->teaser = preg_replace($pattern, $replacement, $string);
                   }
                }
             }
         }
      else {
         $pattern = '/(<a(\s)+[^>]*href(\s)*=(\s)*(\'|")*)([^"\'>]*)#+([^"\'>]+(\'|")*[^>]*(\s)*>(.|\s)*?<\/a(\s)*>)/i'; // "
         if ($node->body) {
            $string = $node->body;
            $replacement = '';
            $node->body = preg_replace($pattern, $replacement, $string);
            }
         if ($node->teaser) {
            $string = $node->teaser;
            $replacement = '';
            $node->teaser = preg_replace($pattern, $replacement, $string);
            }
         }

  }
}

By the way, the occasional comments (//") are just there to unconfuse MPS PHP Designer so that it switches its colour coding back to something coherent!

User Searchable User List (development)

USER SEARCHABLE USER LIST:
I am still fairly new to Drupal but after some thought and initial reading of API's and modules etc. I thought I'd throw in my thoughts and see if anything bounces back (as it is very slow going from the ground up on my own!).

Currently it is possible to view a list of users (details) according to role.
I wish to create a new search/reporting facility that produces sub-sets of this list.
If my ideas rework existing code or are way off base for some reason then please feel free to point in the right direction.

My approach is to be in two phases (unless someone decides to help accelerate it. I need to have phase 1 by end of this month; phase two is the nicer way to do it, but consider phase 1 proof of concept):

Phase One
Phase 1 will
i) create a simple form for user input that lists the available profile fields for the search. This will only be avilable to members of the site (rid>0), and will allow selection of the criteria (from list or checkbox according to the profile_field type)

ii) on form submission the selection criteria will be used to form the data query before calling the function to produce the list of users
OR (if easier/possible for phase 1 )
use an overide of whatever the function is to 'display users list' and only display a user IF all search profile_field values = listing-user-profile_field values.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions