Anchor/Link within post

Started by Ollie_P, June 09, 2010, 04:06:09 AM

Previous topic - Next topic

Ollie_P

I've had a quick search both here and over in the modification section but couldn't seem to find anything.

What I would like to do is create an anchor at different parts of the page so I can link back to it down the page. I've tried [anchor=<text>][/anchor] and [goto=<text>][/goto] but nothing seemed to work.

I attempted to do it in HTML with the <a name="text"></a> <a href ="#text"></a> but it doesn't look like SMF supports that kind of HTML as it didn't do anything with it. Anyone know of a way to do it?

Thanks :)

N3RVE

#1
I copied the following from this sticky at the install / Upgrade Board. It should give you an idea of how to use anchors with Bulletin board code.



These are the Manual Upgrade Instructions for the [url=http://www.simplemachines.org/community/index.php?topic=324169]1.1.10[/url] release. As always, use a reliable PHP editor to modify files.
Use the anchors to link to specific files changes :).

[iurl=#index]./Index.php[/iurl]
[iurl=#ManageAttachments]./Sources/ManageAttachments.php[/iurl]
[iurl=#ManageBans]./Sources/ManageBans.php[/iurl]
[iurl=#ManageRegistration]./Sources/ManageRegistration.php[/iurl]
[iurl=#Packages]./Sources/Packages.php[/iurl]
[iurl=#PersonalMessage]./Sources/PersonalMessage.php[/iurl]
[iurl=#Post]./Sources/Post.php[/iurl]
[iurl=#Profile]./Sources/Profile.php[/iurl]
[iurl=#Register]./Sources/Register.php[/iurl]
[iurl=#Subs-Auth]./Sources/Subs-Auth.php[/iurl]
[iurl=#RegisterTemplate]./Themes/default/Register.template.php[/iurl]

[anchor=index][b]./Index.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.9                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]

$forum_version = 'SMF 1.1.9';
[/code]

[code=Replace with]

$forum_version = 'SMF 1.1.10';
[/code]

[anchor=ManageAttachments][b]./Sources/ManageAttachments.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.9                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
'link' => '<a href="' . ($row['attachmentType'] == 1 ? $modSettings['custom_avatar_url'] . '/' . $row['filename'] : ($scripturl . '?action=dlattach;' . ($context['browse_type'] == 'avatars' ? 'type=avatar;' : 'topic=' . $row['ID_TOPIC'] . '.0;') . 'id=' . $row['ID_ATTACH'])) . '"' . (empty($row['width']) || empty($row['height']) ? '' : ' onclick="return reqWin(this.href + \';image\', ' . ($row['width'] + 20) . ', ' . ($row['height'] + 20) . ', true);"') . '>' . htmlspecialchars($row['filename']) . '</a>'
[/code]

[code=Replace with]
'link' => '<a href="' . ($row['attachmentType'] == 1 ? $modSettings['custom_avatar_url'] . '/' . $row['filename'] : ($scripturl . '?action=dlattach;' . ($context['browse_type'] == 'avatars' ? 'type=avatar;' : 'topic=' . $row['ID_TOPIC'] . '.0;') . 'id=' . $row['ID_ATTACH'])) . '"' . (empty($row['width']) || empty($row['height']) ? '' : ' onclick="return reqWin(this.href + \'' . ($modSettings['custom_avatar_url'] ? '' : ';image') . '\', ' . ($row['width'] + 20) . ', ' . ($row['height'] + 20) . ', true);"') . '>' . htmlspecialchars($row['filename']) . '</a>'
[/code]

[anchor=ManageBans][b]./Sources/ManageBans.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1                                             *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]

[code=Find]
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Find]
if (!empty($updates))
foreach ($updates as $newStatus => $members)
updateMemberData($members, array('is_activated' => $newStatus));
[/code]

[code=Replace with]
if (!empty($updates))
foreach ($updates as $newStatus => $members)
updateMemberData($members, array('is_activated' => $newStatus));

// Update the amount of members awaiting approval
updateStats('member');
[/code]

[anchor=ManageRegistration][b]./Sources/ManageRegistration.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.6                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]


[code=Find]
'send_welcome_email' => isset($_POST['emailPassword']),
[/code]

[code=Replace with]
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']),
[/code]

[anchor=Packages][b]./Sources/Packages.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.8                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]


[code=Find]
'type' => $txt['package56'],
'action' => strtr($action['filename'], array($boarddir => '.')),
[/code]

[code=Replace with]
'type' => $txt['package56'],
'action' => htmlspecialchars(strtr($action['filename'], array($boarddir => '.'))),
[/code]


[code=Find]
'action' => strtr($mod_action['filename'], array($boarddir => '.')),
'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success']
[/code]

[code=Replace with]
'action' => htmlspecialchars(strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success']
[/code]


[code=Find]
'action' => strtr($mod_action['filename'], array($boarddir => '.')),
'description' => $txt['package_action_skipping']
[/code]

[code=Replace with]
'action' => htmlspecialchars(strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_skipping']
[/code]


[code=Find]
'action' => strtr($mod_action['filename'], array($boarddir => '.')),
'description' => $txt['package_action_missing']
[/code]

[code=Replace with]
'action' => htmlspecialchars(strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_missing']
[/code]


[code=Find]
'action' => strtr($mod_action['filename'], array($boarddir => '.')),
'description' => $txt['package_action_error']
[/code]

[code=Replace with]
'action' => htmlspecialchars(strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_error']
[/code]


[code=Find]
'type' => $txt['package57'],
'action' => $action['filename']
[/code]

[code=Replace with]
'type' => $txt['package57'],
'action' => htmlspecialchars($action['filename'])
[/code]


[code=Find]
'type' => $txt['package50'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package55'] : $txt['package54']),
'action' => strtr($action['destination'], array($boarddir => '.'))
[/code]

[code=Replace with]
'type' => $txt['package50'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package55'] : $txt['package54']),
'action' => htmlspecialchars(strtr($action['destination'], array($boarddir => '.')))
[/code]


[code=Find]
'type' => $txt['package53'] . ' ' . ($action['type'] == 'require-dir' ? $txt['package55'] : $txt['package54']),
'action' => strtr($action['destination'], array($boarddir => '.'))
[/code]

[code=Replace with]
'type' => $txt['package53'] . ' ' . ($action['type'] == 'require-dir' ? $txt['package55'] : $txt['package54']),
'action' => htmlspecialchars(strtr($action['destination'], array($boarddir => '.')))
[/code]


[code=Find]
'type' => $txt['package51'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package55'] : $txt['package54']),
'action' => strtr($action['source'], array($boarddir => '.')) . ' => ' . strtr($action['destination'], array($boarddir => '.'))
[/code]

[code=Replace with]
'type' => $txt['package51'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package55'] : $txt['package54']),
'action' => htmlspecialchars(strtr($action['source'], array($boarddir => '.'))) . ' => ' . htmlspecialchars(strtr($action['destination'], array($boarddir => '.')))
[/code]


[code=Find]
'type' => $txt['package52'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package55'] : $txt['package54']),
'action' => strtr($action['filename'], array($boarddir => '.'))
[/code]

[code=Replace with]
'type' => $txt['package52'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package55'] : $txt['package54']),
'action' => htmlspecialchars(strtr($action['filename'], array($boarddir => '.')))
[/code]

[anchor=PersonalMessage][b]./Sources/PersonalMessage.php[/b][/anchor]

[code=Find]
* Software Version:           SMF 1.1.6                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]


[code=Find]
$context['post_error'][$error_type] = true;
if (isset($txt['error_' . $error_type]))
$context['post_error']['messages'][] = $txt['error_' . $error_type];
[/code]

[code=Replace with]
// There is no compatible language string. So lets work around that.
if ($error_type == 'wrong_verification_code')
$txt['error_wrong_verification_code'] = $txt['visual_verification_failed'];

$context['post_error'][$error_type] = true;
if (isset($txt['error_' . $error_type]))
$context['post_error']['messages'][] = $txt['error_' . $error_type];
[/code]

[anchor=Post][b]./Sources/Post.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.9                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
// Check if it's locked.  It isn't locked if no topic is specified.
if (!empty($topic))
[/code]

[code=Replace with]
// No message is complete without a topic.
if (empty($topic) && !empty($_REQUEST['msg']))
{
$request = db_query("
SELECT id_topic
FROM {$db_prefix}messages
WHERE id_msg = " . (int) $_REQUEST['msg'], __FILE__, __LINE__);
if (mysql_num_rows($request) != 1)
unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
else
list($topic) = mysql_fetch_row($request);
mysql_free_result($request);
}

// Check if it's locked.  It isn't locked if no topic is specified.
if (!empty($topic))
[/code]


[code=Find]
// Previewing an edit?
if (isset($_REQUEST['msg']))
{
[/code]

[code=Replace with]
// Previewing an edit?
if (isset($_REQUEST['msg']) && !empty($topic))
{
// Get the existing message.
$request = db_query("
SELECT
m.ID_MEMBER, m.modifiedTime, m.smileysEnabled, m.body,
m.posterName, m.posterEmail, m.subject, m.icon,
IFNULL(a.size, -1) AS filesize, a.filename, a.ID_ATTACH,
t.ID_MEMBER_STARTED AS ID_MEMBER_POSTER, m.posterTime
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MSG = m.ID_MSG AND a.attachmentType = 0)
WHERE m.ID_MSG = " . (int) $_REQUEST['msg'] . "
AND m.ID_TOPIC = $topic
AND t.ID_TOPIC = $topic", __FILE__, __LINE__);
// The message they were trying to edit was most likely deleted.
// !!! Change this error message?
if (mysql_num_rows($request) == 0)
fatal_lang_error('smf232', false);
$row = mysql_fetch_assoc($request);

$attachment_stuff = array($row);
while ($row2 = mysql_fetch_assoc($request))
$attachment_stuff[] = $row2;
mysql_free_result($request);

if ($row['ID_MEMBER'] == $ID_MEMBER && !allowedTo('modify_any'))
{
// Give an extra five minutes over the disable time threshold, so they can type.
if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
fatal_lang_error('modify_post_time_passed', false);
elseif ($row['ID_MEMBER_POSTER'] == $ID_MEMBER && !allowedTo('modify_own'))
isAllowedTo('modify_replies');
else
isAllowedTo('modify_own');
}
elseif ($row['ID_MEMBER_POSTER'] == $ID_MEMBER && !allowedTo('modify_any'))
isAllowedTo('modify_replies');
else
isAllowedTo('modify_any');

[/code]


[code=Find]
// Editing a message...
elseif (isset($_REQUEST['msg']))
[/code]

[code=Replace with]
// Editing a message...
elseif (isset($_REQUEST['msg']) && !empty($topic))
[/code]


[code=Find]
// Posting a new topic.
elseif (empty($topic))
{
[/code]

[code=Replace with]
// Posting a new topic.
elseif (empty($topic))
{
// Now don't be silly, new topics will get their own id_msg soon enough.
unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);

[/code]

[anchor=Profile][b]./Sources/Profile.php[/b][/anchor][code=Find]
* Software Version:           SMF 1.1.9                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
'url' => 'http://www.apnic.net/apnic-bin/whois2.pl?searchtext=' . $context['ip'],
[/code]

[code=Replace with]
'url' => 'http://wq.apnic.net/apnic-bin/whois.pl?searchtext=' . $context['ip'],
[/code]


[code=Find]
'url' => 'http://ws.arin.net/cgi-bin/whois.pl?queryinput=' . $context['ip'],
[/code]

[code=Replace with]
'url' => 'http://ws.arin.net/whois/?queryinput=' . $context['ip'],
[/code]


[code=Find]
'url' => 'http://www.ripe.net/perl/whois?searchtext=' . $context['ip'],
[/code]

[code=Replace with]
'url' => 'http://www.db.ripe.net/whois?searchtext=' . $context['ip'],
[/code]

[anchor=Register][b]./Sources/Register.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.6                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]


[code=Find]
if (trim($_POST['realName']) != '' && !isReservedName($_POST['realName'], $memID) && $func['strlen']($_POST['realName']) <= 60)
[/code]

[code=Replace with]
if (trim($_POST['realName']) != '' && !isReservedName($_POST['realName']) && $func['strlen']($_POST['realName']) <= 60)
[/code]

[anchor=Subs-Auth][b]./Sources/Subs-Auth.php[/b][/anchor]
[code=Find]
* Software Version:           SMF 1.1.6                                           *
[/code]

[code=Replace with]
* Software Version:           SMF 1.1.10                                          *
[/code]


[code=Find]
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
[/code]

[code=Replace with]
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
[/code]


[code=Find]
// Version 4.3.2 didn't store the cookie of the new session.
if (version_compare(PHP_VERSION, '4.3.2') === 0)
setcookie(session_name(), session_id(), time() + $cookie_length, $cookie_url[1], '', 0);
[/code]

[code=Replace with]
// Version 4.3.2 didn't store the cookie of the new session.
if (version_compare(PHP_VERSION, '4.3.2') === 0 || (isset($_COOKIE[session_name()]) && $_COOKIE[session_name()] != session_id()))
setcookie(session_name(), session_id(), time() + $cookie_length, $cookie_url[1], '', 0);
[/code]

[anchor=RegisterTemplate][b]./Themes/default/Register.template.php[/b][/anchor]
[code=Find]
// Version: 1.1.5; Register
[/code]

[code=Replace with]
// Version: 1.1.10; Register
[/code]


[code=Find]
if (document.forms.postForm.emailActivate.checked)
[/code]

[code=Replace with]
if (document.forms.postForm.emailActivate.checked || document.forms.postForm.password.value == \'\')
[/code]


[code=Find]
<input type="password" name="password" id="password_input" size="30" /><br />
[/code]

[code=Replace with]
<input type="password" name="password" id="password_input" size="30" onchange="onCheckChange();" /><br />
[/code]


[code=Find]
<input type="checkbox" name="emailPassword" id="emailPassword_check" checked="checked"', !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? ' disabled="disabled"' : '', ' class="check" /><br />
[/code]

[code=Replace with]
<input type="checkbox" name="emailPassword" id="emailPassword_check" checked="checked" disabled="disabled" class="check" /><br />
[/code]
[hr]
Finally, run this SQL query to update the [color=green]smfVersion[/color] variable in your forum's database.
Open phpMyAdmin ([url=http://www.simplemachines.org/community/index.php?topic=21919.0]What is phpMyAdmin?[/url]) -> SMF's DB -> SQL ->

[code=Run]
UPDATE `smf_settings` SET `value` = '1.1.10' WHERE `variable` = 'smfVersion' LIMIT 1 [/code]

The SQL query above works if the database tables prefix for your forum is [b]smf_[/b] (which is the default). The actual prefix for your forum can be found in the Admin CP -> Server Settings -> "Database Tables Prefix" or as the value for [php]$db_prefix[/php] in [tt]Settings.php[/tt] (which is located in your forum directory).



-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Ollie_P

So a quick version:


  • An [iurl] at the top to define the place where you want to go back to,
  • An [anchor=<text>] to go back to it

Did I get that right?  :o

Arantor

No, other way around. anchor specifies the destination, iurl (internal URL) is the actual clickable link.

Advertisement: