Forum: Radiant CMS r:link and hosting multiple sites off a single radiant insta

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2c51fec8183a5d21c4e11b430beabb47?d=identicon&s=25 Patrick Hurley (Guest)
on 2007-01-17 06:49
(Received via mailing list)
After reading the suggestion at
http://dev.radiantcms.org/radiant/wiki/HowToHostMu...

I tried setting up just such a system. It largely works; however,
unsurprisingly the r:link tag is thoroughly confused. As radiant does
not know that apache is "rehoming" all of its tags, I get goofed up
links.

If I am missing something and there is an easy way around this
problem, please let me know. If not one thing that is working for me
is this simple patch against r:link, allowing for a "base" option that
is removed from the front of the url.

Thanks for Radiant
pth

Index: /Users/phurley/mental/radiant/app/models/standard_tags.rb
===================================================================
--- /Users/phurley/mental/radiant/app/models/standard_tags.rb  (revision
233)
+++ /Users/phurley/mental/radiant/app/models/standard_tags.rb  (working
copy)
@@ -340,10 +340,13 @@
   tag 'link' do |tag|
     options = tag.attr.dup
     anchor = options['anchor'] ? "##{options.delete('anchor')}" : ''
+    base = options['base'] ? options.delete('base') : nil
     attributes = options.inject('') { |s, (k, v)| s <<
%{#{k.downcase}="#{v}" } }.strip
     attributes = " #{attributes}" unless attributes.empty?
     text = tag.double? ? tag.expand : tag.render('title')
-    %{<a href="#{tag.render('url')}#{anchor}"#{attributes}>#{text}</a>}
+    url = tag.render('url')
+    url = url.sub(/^#{base}/,'') if base
+    %{<a href="#{url}#{anchor}"#{attributes}">#{text}</a>}
   end

   desc %{   <r:breadcrumbs [separator="separator_string"] />
This topic is locked and can not be replied to.