Jul 05, 2009, 09:27 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1]   Go Down
  Print  
Author Topic: [Plugin] AliasLinks  (Read 10154 times)
0 Members and 1 Guest are viewing this topic.
OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« on: Feb 07, 2006, 04:05 PM »

As requested by someone on the #modx IRC channel, here is a short, sweet plugin for placing links in your content using the [~~] tag format by alias.

Example usage:
[~[+alias:actual-doc-alias-here+]~]

This will return the relative link to the document using the proper alias (if friendly_alias_urls is enabled), prefix, suffix, and alias path (if friendly_alias_paths is enabled).  Please note, you must have friendly_urls enabled to use this, and you must make sure that every alias exists that you create a link to, otherwise, the parser in 0.9.1 will return an error like this:
Code:
Fatal error: Cannot use [] for reading in C:\dev\xampp\htdocs\modx\manager\includes\document.parser.class.inc.php(807) : regexp code on line 1


Here is the plugin code:
Code:
//AliasLinks plugin

$e = &$modx->event;
switch ($e->name) {
case "OnWebPageInit":
if ($modx->config['friendly_urls'] == 1) {
if (is_array($modx->documentListing)) {
foreach ($modx->documentListing as $linkAlias=> $linkDocId) {
$modx->setPlaceholder("alias:{$linkAlias}", "{$linkDocId}");
}
}
}
break;

   default :   
      return; // stop here - this is very important.
}

You'll need to enable the plugin for the OnWebPageInit event.  Let me know if you have any questions.
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #1 on: Feb 09, 2006, 08:45 AM »

Will this be added to the future release?
Logged

sirvanderwaal
Jr. Member
*
Posts: 15



WWW
« Reply #2 on: Feb 20, 2006, 11:59 PM »

This is an AMAZING plugin! It should receive much more credit on the site! Good work!

-Andy
Logged
davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #3 on: Feb 21, 2006, 03:11 AM »

Agreed Andy !

How did I miss that ?!?

It will be most certainly be of great use Grin
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #4 on: Feb 21, 2006, 08:41 AM »

Added to repository
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #5 on: Feb 28, 2006, 02:47 PM »

Also, if you want to build them using the alias instead of the id, you can take a look at my AliasLinks plugin at http://modxcms.com/forums/index.php/topic,2763.0.html -- you could use those in conjunction with #anchor links as well, like so:
Code:
[~[+alias:somepagealias+]~]#anchor
This might be useful for creating portable content dependent on aliases instead of document ids.
And FYI, [*alias*] only gets the current document's actual alias, not the full alias path as is applied via the [~~] tags, but this may be possible with the plugin, though I haven't tried it:
Code:
[~[+alias:[*alias*]+]~]#anchor

Just some other options I wanted to point out.
Logged

bugsmi0
Sr. Member
****
Posts: 356


« Reply #6 on: Jul 02, 2006, 07:29 AM »

I don't get it how does this work ?

[~[+alias:actual-doc-alias-here+]~]

i tried it but no link  [~[+alias:aliasname+]~]

are we suppose to put doc id with it ?
Logged

numberblack
Jr. Member
*
Posts: 8


WWW
« Reply #7 on: Nov 11, 2007, 08:09 AM »

I will renew this topic, because i also have the problem with creating alias links. I have the newest veriosn of modcsms
I installed, and enabled the plugin, but it doesnt work.

When i try to link, the tag [~44~] works fine, and outputs a firendly link to http://mysite.com/category/alias-for-id-44.html but

the command [~[+alias:alias-for-id-44+]~] doesnt work at all. I recieve a link which looks like that http:/mysite.com/[~~]
I tried many combinations of [ ] [[ ]] [++] [~~] but none was working

Has anyone solved this clue?

Logged

modx is amazing and brilliant.  So is modx community!
znorelo
Member
**
Posts: 70


WWW
« Reply #8 on: Jan 09, 2008, 10:42 AM »

I have the same problem. Has enyone found a solution ?

Regards.
Logged

Aurélien Chappard
Concepteur Developpeur Multimédia
http://www.aurelienchappard.fr
prioritypie
Jr. Member
*
Posts: 12


« Reply #9 on: Feb 28, 2008, 07:08 AM »

AliasLinks was working fine on my site until I added the PHx plugin. Now it doesn't work at all. It looks like PHx somehow strips the alias: placeholder. Any ideas on how to get around this?
Logged
snaaps50
Jr. Member
*
Posts: 11


« Reply #10 on: Mar 15, 2008, 06:23 PM »

Here it dont work.

Only [~id~] works, but links to: http://alias-name.html
(no domainname or subdirectory)
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!