Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Access to a url query when add_link is used


Go to End


1119 Views

Avatar
simples

Community Member, 77 Posts

21 October 2014 at 9:59pm

I am trying to add extra functionality to the CMS by calling the add_link function to add links to the top horizontal menu of the CMS.

One of these links link to a standalone PHP script which exists outside the Silverstripe framework.

The link in LeftAndMain.php is as follows

CMSMenu::add_link(
'RegisteredUsers',
'RegisteredUsers',
'module_my/code/show_members.php?status=1'
);

No GET variable is being sent to show_members.php. Indeed both $_REQUEST and $_SERVER['QUERY_STRING'] are empty.

Question: How can I retrieve the value of the GET variable in my show_members.php script?

Some more details

Something in my .htaccess file may be causing this. I see that this file contains the following lines.

<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>

However these lines are gibberish to me and I do not know how .htaccess and these lines get accessed.

Indeed inserting lines in sapphire/main.php just before the call to Director::direct($url); to print the value of $url to a log file inserted the following

admin
admin/EditorToolbar/ImageForm

I interpret this to mean that main.php is not being called after the link is clicked.

My external script contains the following code

<?php
include('My.php');
$myMy=new My();
$myMy->showMembers();
?>

My.php contains all my functions of which showMembers is one. My.php starts and ends with this

class My{
...
...
}

As you can see in my call to CMSMenu, My.php is located at root/module_my/code

I am using Silverstripe 2.4.