Modifying links

12 views
Skip to first unread message

NicholasJohn16

unread,
Feb 27, 2012, 10:28:48 PM2/27/12
to simplewiki
Hello there!

First of all, thanks for letting me join and writing this great
module! I've been wanting a Wiki component for the Joomla Platform
for sometime and thanks to your module a ton of the work is done for
me!!

Secondly, I'm a noob. :( I'm pretty new to PHP programming and this
is third component I've written for Joomla so I'm probably gonna ask a
lot of really stupid questions. I hope not to bother you too much
though.

If you're not familiar, Joomla! is a Content Management System (CMS).
You can read more about it at joomla.org.

Okay, the first obstacle I've run into is that I need to modify how
links are generated by the module. Instead of just being /target, I
need to add some get variables into the URL so Joomla knows what to
direct to, specifically 'index.php?
option=com_jwiki&title=target&itemid=99'.

I'm assuming I need to override one of the class functions in a shell,
but I'm not sure to do it in the parser or the emitter. I'm thinking
either the _link_node or _link_emit functions. Or is there a better
way to do this?

Any assistance you can provide would be appreciated.

I have another slightly related question, when I use the syntax as
[[link]] to generate a link to a new page, it's rendered with a dashed
underline and a question mark. Why is this? Isn't that the way to
create links in Creole? I see the SimpleWiki syntax calls for
[[Local:link]] to generate links without the dashed underline and
question mark. I see the functions that are responsible for this, can
I override them as well somehow? This is mainly to simplify the
syntax a bit, but if there's a specific reason for it, I'm happy to
leave it be.

Anywho, thank you very much for your help!

Nick

NicholasJohn16

unread,
Feb 27, 2012, 10:40:50 PM2/27/12
to simpl...@googlegroups.com
Oh dear, I really should've read first then posted. I now see there are a few posts covering just this. I'll give them a read in the morning and see if I have any questions after that.

Henrik Bechmann

unread,
Feb 28, 2012, 8:41:43 AM2/28/12
to simpl...@googlegroups.com
Hi Nicholas, and welcome!

I'll respond to your detailed questions later today.

Best,

- Henrik


--
You received this message because you are subscribed to the Google Groups "simplewiki" group.
To post to this group, send email to simpl...@googlegroups.com.
To unsubscribe from this group, send email to simplewiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simplewiki?hl=en.




--
bechmann.ca

NicholasJohn16

unread,
Feb 28, 2012, 3:44:55 PM2/28/12
to simplewiki
I was able to get the links to work correctly using the
register_symlinks function I found <a href="https://groups.google.com/
group/simplewiki/browse_thread/thread/313ec5b47c9a79fd?hl=en">here</
a>.

Though, I haven't gotten figured out how to remove the Local part. I
read <a href="https://groups.google.com/group/simplewiki/browse_thread/
thread/d09573a7db6ee083?hl=en">here</a> that you were planning
something called monolink, but I can't find it in the documentation or
code anywhere.

Thanks Henrik. It's much appreciated. :)

On Feb 28, 8:41 am, Henrik Bechmann <hen...@bechmann.ca> wrote:
> Hi Nicholas, and welcome!
>
> I'll respond to your detailed questions later today.
>
> Best,
>
> - Henrik
>
> On Mon, Feb 27, 2012 at 10:28 PM, NicholasJohn16
> <nicholasjoh...@gmail.com>wrote:

Henrik Bechmann

unread,
Feb 28, 2012, 4:15:07 PM2/28/12
to simpl...@googlegroups.com
Nicholas,

There's another registration called 

register_rawlink_handler($handler)

which requires you to register a callback method (or function). This is called only if the parser has found none of:

a valid protocol
a symlink (starts with capital letter, ends with colon)
an anchor (starts with #)

Your callback is handed a $node object, and is expected to return the $node object.

Something like

public function mylinkhandler($node)
{
 $rawlink = $node->linkparts->rawlink; // this is the link set by the user in [[somerawlink|go somewhere]]

// validate $rawlink here, and expand to valid href value (relative directory addressing s/b OK)

// if link is invalid, set $node->unknown = TRUE; and return $node before next line - this causes the dashed underline and question mark to alert the author

$node->linkparts->rawlinkaddress = "mywikipagespath/" . $rawlink; // or some valid href value

 return $node;
}

Then the emitter includes your rawlinkaddress in the output.

If that method was part of your MyWiki class, the registration would be something like

$simplewiki = new SimpleWiki();

$mywiki = new MyWiki();

$simplewiki->register_rawlink_handler(array($mywiki,"mylinkhandler"));

There's some documentation about docnode properties in the docnode.php file.

Note that to debug the contents of a node, you can use 

var_dump($node->get_display_list());

which avoids parent and children nodes. You can call this inside your callback method.

Hope this helps.

Best,

- Henrik

NicholasJohn16

unread,
Feb 29, 2012, 12:41:38 PM2/29/12
to simpl...@googlegroups.com
Wow!  Thank you so much!  That was shockingly easy to use and lays the groundwork for a lot of the stuff I was wanting to do.

I was able to extrapolate based on this and found the register_symlink_handler.  With that, I've set up a really cool User namespace where, for example, [[User:Username]] automatically links to a person's profile.  I've also started the basis for a Special namespace.

I think that answers all my questions for now, but I'll probably be back soon to pick your brain some more.

Thanks again Henrik!

Henrik Bechmann

unread,
Feb 29, 2012, 1:24:03 PM2/29/12
to simpl...@googlegroups.com
Excellent!

Keep in touch...

- Henrik

--
You received this message because you are subscribed to the Google Groups "simplewiki" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simplewiki/-/TWrPbSlBB2sJ.

To post to this group, send email to simpl...@googlegroups.com.
To unsubscribe from this group, send email to simplewiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simplewiki?hl=en.
Reply all
Reply to author
Forward
0 new messages