Author Topic: External links  (Read 1788 times)

abicio

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
External links
« on: September 13, 2009, 07:44:15 PM »
Hi, how could I insert a menu item which point to an external link? (In the menu manager I can only associate menu item with internal pages...)

thank you!

youcantryreachingme

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +1/-0
    • View Profile
Re: External links
« Reply #1 on: September 14, 2009, 03:15:47 AM »
It's not straightforward.

One solution is to create a page in your website, say "external-link-1" (or something). Then edit your .htaccess file and add a rule to forward the corresponding address to the external link.

It's ugly, but it gets your link into the menu.

I have added a similar link using another method, which is to hard-code the link in the menu's output. Sorry, I don't have the details to hand about what files to change, but if you really want to go about it this way, let me know.

An infinitely better solution would be an update to compactcms to allow external links ;)

Chris.

abicio

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: External links
« Reply #2 on: September 14, 2009, 09:24:15 AM »
thank you very much, I'll try the first solution, waiting for a compactcms upgrade...  ;D

abicio

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: External links
« Reply #3 on: September 15, 2009, 12:01:43 AM »
Mmm...I cannot redirect my link  :(

In the admin panel I create a page named foto.html, then in the htaccess file i added:

RewriteRule ^foto\.html$       foto/index.php [L]

I want to redirect the user from foto.html to foto/index.php, but it doesn't work, the website show me content of foto.html  :-[

Where am I wrong?

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: External links
« Reply #4 on: September 15, 2009, 05:47:04 PM »
Hi!

This might be caused by the location of your line within the .htaccess file. If this rule isn't on top of:

Code: [Select]
RewriteRule ^([^/]+)\.html$ index.php?page=$1 [L]
Your new rule will never be applied. Another option by the way could be to add the following code to your ./content/foto.php file:


<?php  
header
("HTTP/1.0 301 Moved Permanently"); // Optional
header("Location: http://yoursite.com/foto/index.php"); 
exit();
?>  


This would get you the same result, without a noticable delay on the users' end (to the best of my knowledge). In the mean time I'd love to help you on making such a feature, but as written in another post, I could use some suggestions, tips on how to best implement this.

Cheers,
Xander.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

abicio

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: External links
« Reply #5 on: September 15, 2009, 08:47:21 PM »
The first line works, thank you!  ;)

With this:


<?php  
header
("HTTP/1.0 301 Moved Permanently"); // Optional
header("Location: http://yoursite.com/foto/index.php"); 
exit();
?>  



I obatin this error  (I think it's because the page generated by compactcms has already a header)


Warning: Cannot modify header information - headers already sent by (output started at D:\Internet\xampp\htdocs\latindancemachine\admin\handler.inc.php:68) in D:\Internet\xampp\htdocs\latindancemachine\content\foto.php on line 2
« Last Edit: September 16, 2009, 12:21:58 AM by abicio »

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: External links
« Reply #6 on: September 16, 2009, 01:44:24 AM »
The content in CCMS gets flushed. I just tried this at the demo with this page. Check the source for this file using the administration. All I added was:

<?php header("Location: http://www.compactcms.nl"); exit(); ?>

Anyway, even if this won't work, I've also tried the following .htaccess lines locally to see whether installation.html gets redirected to the specified url. It works, so this should work for you too, since - to the best of my knowledge - its generic Apache formatting.

Code: [Select]
RewriteRule ^installation\.html$ http://www.compactcms.nl [L]
RewriteRule ^([^/]+)\.html$ index.php?page=$1 [L]
RewriteRule ^print/([^/]+)\.html$ afdrukken.php?page=$1 [L]
RewriteRule ^admin/includes/js/(.+\.js)$ admin/includes/combine.inc.php?type=javascript&files=$1 [L]
RewriteRule ^admin/img/styles/(.+\.css)$ admin/includes/combine.inc.php?type=css&files=$1 [L]
RewriteRule ^sitemap\.xml$ lib/sitemap.php [L]

Let me know if it works! In the mean time I still think about programming a mechanism to automatically make the link behind a page set to an external url if the description contains a full url (http://domain.com). This way it is clear what page it is about and it can easily be managed without changing anything in the database structure. Unless you have any negatives on this approach I'll consider fixing it this way. Changing the file name or adding extra clicks through pop-ups sounds not too user friendly to me.

Thanks!
Xander.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

abicio

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: External links
« Reply #7 on: September 16, 2009, 03:04:39 PM »

Code: [Select]
RewriteRule ^installation\.html$ http://www.compactcms.nl [L]
RewriteRule ^([^/]+)\.html$ index.php?page=$1 [L]
RewriteRule ^print/([^/]+)\.html$ afdrukken.php?page=$1 [L]
RewriteRule ^admin/includes/js/(.+\.js)$ admin/includes/combine.inc.php?type=javascript&files=$1 [L]
RewriteRule ^admin/img/styles/(.+\.css)$ admin/includes/combine.inc.php?type=css&files=$1 [L]
RewriteRule ^sitemap\.xml$ lib/sitemap.php [L]


this is ok..

In the mean time I still think about programming a mechanism to automatically make the link behind a page set to an external url if the description contains a full url (http://domain.com). This way it is clear what page it is about and it can easily be managed without changing anything in the database structure. Unless you have any negatives on this approach I'll consider fixing it this way. Changing the file name or adding extra clicks through pop-ups sounds not too user friendly to me.

here http://community.compactcms.nl/forum/index.php/topic,23.0.html you can find some suggestions :)