Creating links to an intermediary page is going to wind up ruining search engine optimisation. Instead of linking to /freelinking/whatever, we can easily construct a path to the proper page path.

CommentFileSizeAuthor
#1 proper_links_0.patch1.09 KBceejayoz
proper_links.patch1.09 KBceejayoz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ceejayoz’s picture

FileSize
1.09 KB

Sorry, I seem to have left the '.old' in the old filename. Try this version instead:

laghalt’s picture

This is right - besides that the patch only work in some cases (havent figured out wich ones) - and that it makes the "add node" function without the name of the node (minor problem).

awgrover’s picture

I was tempted by this idea too. Here's the cases I can think of:

  1. The node already exists. So, just put the url in place
  2. The node doesn't exist. We want this to go to "create node x", but then change it when the node is created. How would you do that?
  3. The node already exists, but gets deleted later. We want the link to go to "node x", but then act like "create node x" when the node gets deleted (as in case 2). How would you fixup the links?
  4. The node could change its title later. How would you handle that?
  5. The freelink has to be editable (in raw, TinyMCE, etc.), appearing as [[...]] or CamelCase.

Traditional Wiki's handle this by replacing the "freelink" at display time (regexp replace). Renaming a page is dealt with by regexp-replace'ing the freelink in all the wiki-pages.

I considered generating <a class="freelink" ...>, which is findable/replaceable. However, when we need to fix the href, how do we find all the text (body, fields, etc.) of each node type.

Perhaps we could put in php-code to calculate the href, and cache the calculation. Flush the cache anywhere that creates/deletes a page, or changes its title. Can we put a hook in for all cases of title change? On edit, we replace the php-block with the freelink ([[...]]/CamelCase). Are filters "bi-directional" (transform on display & submit)?

None of this seemed like a good idea.

mlncn’s picture

Subscribing. I think the retease module does whatever is needed to regenerate input filters output.

This might not be at all impractical to do every time a new node title matches a freelinking link.

ben, Agaric Design Collective

rand0mmm’s picture

Uh, something like this is BITING my little install.

I am new to DRUPAL, but using alot of perl wiki stuff, php galleries, css, etc.

Setup seems good. Glad to find wiki creole inside PEAR wiki module.
Installed Freelinking, and wikitools as well. Running on all latest stuff. Maybe there are better older versions???

Well now I see links like [[Contact]] behaving badly...
As an admin I see: http://mysite.com/?q=node/7 (which opens and works fine)
but as an anonymous user, I see: http://mysite.com/?=freelinking/Contact (which breaks: "You are not authorized to view this page")
but if I click on the Contact primary link... http://mysite.com/?q=node/7 (which opens and works fine)

Have tried turning toggling the wikitools ability to hijack freelinks. No difference. Both work equally badly.
have tried adjusted user permissions for content; also freelinks, none there but sidebar links option.

Any ideas or suggestions welcome.

DRUPAL rearrranged: URLPAD

dugh’s picture

subscribe

SamRose’s picture

I tried this patch. It seems to be working but retease did not seem to make a difference for what is discussed in http://drupal.org/node/156523#comment-577014 above (#2)

Owen Barton’s picture

Subscribe

Gerard McGarry’s picture

I've installed the patch, and while it seems to fix freelinks that exist, it does break the link where a page creation has to happen.

Looking at the patch code (disclaimer: I'm no PHP expert), but shouldn't it be possible to distinguish if the string has '/node/add/wiki' in it, and if that's the case, serve up the freelinking link, but otherwise serve up the direct link to the page a la modified patch code.

Let me try and mock something up here...around line 280 of the freelinking.module (in my installation), there's a line which reads

$replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), array('class' => 'freelinking'));

What if this was replaced with an IF statement that serves the original line if the page doesn't exist, but serves the real link if the page does exist? I'm thinking about something like this (apologies in advance for substandard PHP code)

$thereallink = _freelinking_make_link($phrase);
if (substr($thereallink, 0) == '/node/add') {
    $replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), array('class' => 'freelinking'));
    } else {
    $replacement = l($phrase, $thereallink['path'], array('class' => 'freelinking'));
    }

As I say, I have next to no PHP experience, and I suspect the usage of substr() is dodgy, but does this raise a possibility of fixing the freelinking filter so that valid links are done properly?

aflores3’s picture

subscribe

Flying Drupalist’s picture

Anything for 6.x?

tignux’s picture

subscribe

arhak’s picture

subscribing

BTW: would be nice this module render without taking into account filter's cache while keeping track of the links rendered, then when some new node is created or an existing node deleted this module would hook into nodeapi to know if it affects any rendered link, so it would delete the cached version of the rendered node.

Roulion’s picture

subscribing for D6
if this could work, can we add a special css class for existing content (and thus be able to see which node have to be created)

arhak’s picture

+1 for different css for each kind of link (existing ones, pending, even external vs internal, and so on)
[edit] BTW, any css improvement would be a "feature request" and should go to a different issue, please don't mess up the issue queue mixing subjects

Gerard McGarry’s picture

OK, three months later, and I think I may have a solution for this issue. Now, my solution is for Drupal 6 - I'm not sure if this code can be backported to D5, but I have this running on version 6.x.1.7 of the Freelinking module and it gives direct links to existing nodes while using a /freelinking path to link to non-existant nodes.

In response to some of the comments above, I've added a css class called noexist for anyone who wants to use CSS to theme missing nodes. I've also added the rel=nofollow attribute so that non-existant pages aren't followed by search engines.

I have no idea how to submit a patch, so here's how I edited the file - perhaps someone can help put a patch submission together for this?

At line 479 of freelinking.module, the following line can be found:

        $replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), array('attributes' => array('class' => 'freelinking')));

I replaced this with

      	$flnkexists = _freelinking_exists($freelink);
      	if ($flnkexists) {
      		$replacement = l(html_entity_decode($phrase), drupal_get_path_alias('node/' . $flnkexists));
      	} else {
      		//link doesn't exist - apply nofollow
      		$lnkoptions = array('attributes' => array('class' => 'freelinking noexist','rel' => 'nofollow'));
      		$replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), $lnkoptions);
       	}

This works for me, although sometimes it takes you to save an edit to the current page to force the links to update. Is this a possible caching issue?

arhak’s picture

where is considered the cached version?
if the nodes are created or deleted the existence won't be updated since it will be cached
also would be needed to demand the erasure of the cached version whenever a creation/deletion is detected, therefore it would be needed to track that hooking on nodeapi

Roulion’s picture

it works for me also. and with we can add a specific css style to non-exsting node linkswhich is cool

thanks

eafarris’s picture

Version: 5.x-1.2 » 6.x-2.x-dev
Status: Needs review » Fixed

A freelinking-6.x-2.x branch exists to handle this feature. The latest version of Gerard's code is used.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Roulion’s picture

Version: 6.x-2.x-dev » 6.x-1.9
Category: bug » feature
Status: Closed (fixed) » Active

Changing, line 485

$replacement = l(html_entity_decode($phrase), 'freelinking/' . $freelink, array('attributes' => array('class' => 'freelinking')));

and, line 493

$replacement = l($wikiword, 'freelinking/' . urlencode($wikiword), array('attributes' => array('class' => 'freelinking')));

with

      $flnkexists = _freelinking_exists($freelink);
      if ($flnkexists) {
      $replacement = l(html_entity_decode($phrase), drupal_get_path_alias('node/' . $flnkexists));
      } else {
      //link doesn't exist - apply nofollow
      $lnkoptions = array('attributes' => array('class' => 'freelinking noexist','rel' => 'nofollow'));
      $replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), $lnkoptions);
       }

in freelinking .1.x seems to work properly, in order to have specific style for existing freelinks and non-existing freelinks

Is there a way to integrate it

Roulion’s picture

Version: 6.x-1.9 » 6.x-1.10
Grayside’s picture

Status: Active » Closed (won't fix)

Freelinking 1.x is feature-frozen. If you want to create a patch I will link to it from the project page.

The 3.x line is a complete break with the features/ path.