|Link to another page from site|
I have a script and i need to do some modifications , there i have this part of code :
$_output = '<div class="memhome_link">';
$distance = app_NeighbourhoodList::getDefaultDistance(SK_HttpUser::profile_id());
$mode = app_NeighbourhoodList::getProfileSelectedLocationforNeigh(SK_HttpUser::profile_id());
$_output.= '<a href="'.SK_Navigation::href( 'profile_location_list' ).'?mode='.app_NeighbourhoodList::getProfileSelectedLocationforNeigh(SK_HttpUser::profile_id()).( $distance ? '&distance='.$distance : '' ).'" '.$class.'>'.$lang_section->text( 'href_my_location_list').'</a>';
$_output.= ' ('.app_NeighbourhoodList::getList($mode , SK_HttpUser::profile_id(), true, ($distance ? $distance : false) ).')';
So this code sends the member when clicks to a page defined by the script.
Here's what i need : to send the member to another external page , so where do i add the link i want in this code ?
I did tried lots of times , but no results when i'm just guessing :)
Thanks so much in advance .
'K, well, I am not familiar with this code, but am a programmer, let me see if I can explain what's happening which may or may not lead to an answer. I don't know that can be done the way it's implemented.
First, you do not want to edit this code. You will break it. I'm not sure if it's PHP or perl, likely one or the other, but the interpretation will be similar. I'm not explaining "it all", just the cliff notes.
|case 'location_list':.... break; |
A case structure is a "switch" similar to an if then construct, so if the parameter matches the case, it executes this chunk. Guessing you've figured that out by posting it. :-)
|$_output = '<div class="memhome_link">'; |
Well named, the variable $_quote is the location in memory the output is being stored, this is where it starts building the link div.
In perl and PHP, you "assemble" strings in a variety of ways, here it's done with the concatenation operator, the dot. Example,
$var = 'Foo';
$iable = 'Bar';
echo $var . " " . $iable;
will print "Foo Bar" to the screen. Above, I've used literal values to store in the variables, but you can store the output from a function in a variable, and that is what they are doing.
"Where" the link is happening: they are concatenating output from several functions that are derived from class objects. You don't need to know what that means (and may not be entirely accurate anyway) but the reason for my explanation leads to **why** you may not be able to change it to an external link. I've taken the relevant part and broken it line by line, the comments # explain what each appears to be doing.
# add the next part to the $_output variable
# start the link
# Some class/module holds a function 'href' from a class 'SK_Navigation'
# that accepts a parameter, 'profile_location_list',
# This is where the link is being created. So far, we have
# <a href="somescript.cgi
SK_Navigation::href( 'profile_location_list' ).
# Now, it's adding a query string to the link with the variable "mode".
# This is the problem. We now have <a href="somescript.cgi?mode=
# A function 'getProfileSelectedLocationforNeigh' from the class
# 'app_NeighbourhoodList' is passing a parameter extracted from
# ANOTHER function, 'profile_id()', in the class/module 'SK_HttpUser'.
# so we now have <a href="somescript.cgi?mode=some-value
# If there is a value for distance, add to the query string, otherwise, make it blank
# so now we may have <a href="somescript.cgi?mode=some-value&distance=1234
# OR still <a href="somescript.cgi?mode=some-value. Note that the unencoded
# ampersand is invalid (X)HTML, needs to be &
( $distance ? '&distance='.$distance : '' ).
# add the closing quote, link part is complete, we have
# <a href="somescript.cgi?mode=some-value&distance=1234"
# if there is a class styling for this link, add it, add closing
# carat, so now we may or may not have
<a href="somescript.cgi?mode=some-value&distance=1234" class="mylink-class">
# The text is extracted from some object $lang_selection for the parameter
# 'href_my_location_list'. Add the text and closing </a>
# <a href="somescript.cgi?mode=some-value&distance=1234" class="mylink-class">Text here</a>
The actual link will be set by a database setting or configuration somewhere for 'href_my_location_list'. This is the first reason I think it won't be possible, it's very likely that is an automatically generated link, as in a CMS or a cart setting.
Secondly, because it opens with this,
and the name of the parameter,
I am led to believe this is not a single link but generates a LIST of links.
If you modify this code and hard code your link in that location, any requests to this chunk of code will fail, breaking other areas of your site.
The second reason I think it may no work is that if you manage to change the database entry (or wherever it's extracted,) it will add the query string to it, like
Which may be fine, but if the receiving site parses the query string, it will give unexpected results.
Err, $_output, I meant . . .