Skip to main content
Topic: Move Quick Login to under linktree (Read 2409 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Move Quick Login to under linktree

Okay, on my site, one of my themes, is having the quick login "Notice bar" wide and between my logo and slogan.
I'd like to move it, to under the linktree, if can.

Here is what I'd like moved:

Code: [Select]
/**
 If the user is logged in, display the time, or a maintenance warning for admins.
 @todo - TBH I always intended the time/date to be more or less a place holder for more important things.
 The maintenance mode warning for admins is an obvious one, but this could also be used for moderation notifications.
 I also assumed this would be an obvious place for sites to put a string of icons to link to their FB, Twitter, etc.
 This could still be done via conditional, so that administration and moderation notices were still active when applicable.
 */
function template_th_login_bar()
{
global $context, $modSettings, $txt, $scripturl, $settings;

echo '
<div id="top_section_notice" class="user">
<form action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="UTF-8" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div id="password_login">
<input type="text" name="user" size="10" class="input_text" placeholder="', $txt['username'], '" />
<input type="password" name="passwrd" size="10" class="input_password" placeholder="', $txt['password'], '" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" />
</div>
<input type="hidden" name="hash_passwrd" value="" />
<input type="hidden" name="old_hash_passwrd" value="" />
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />';

if (!empty($modSettings['enableOpenID']))
echo '
<a class="button_submit top_button" href="', $scripturl, '?action=login;openid"><img src="' . $settings['images_url'] . '/openid.png" title="' . $txt['openid'] . '" alt="' . $txt['openid'] . '" /></a>';
echo '
</form>
</div>';
}

/**
 * A simple search bar (used in the header)
 */
function template_th_search_bar()
{
global $context, $modSettings, $txt, $scripturl;

echo '
<form id="search_form" action="', $scripturl, '?action=search;sa=results" method="post" accept-charset="UTF-8">
<label for="quicksearch">
<input type="text" name="search" id="quicksearch" value="" class="input_text" placeholder="', $txt['search'], '" />
</label>';

// Using the quick search dropdown?
if (!empty($modSettings['search_dropdown']))
{
$selected = !empty($context['current_topic']) ? 'current_topic' : (!empty($context['current_board']) ? 'current_board' : 'all');

echo '
<label for="search_selection">
<select name="search_selection" id="search_selection">
<option value="all"', ($selected == 'all' ? ' selected="selected"' : ''), '>', $txt['search_entireforum'], ' </option>';

// Can't limit it to a specific topic if we are not in one
if (!empty($context['current_topic']))
echo '
<option value="topic"', ($selected == 'current_topic' ? ' selected="selected"' : ''), '>', $txt['search_thistopic'], '</option>';

// Can't limit it to a specific board if we are not in one
if (!empty($context['current_board']))
echo '
<option value="board"', ($selected == 'current_board' ? ' selected="selected"' : ''), '>', $txt['search_thisbrd'], '</option>';

if (!empty($context['additional_dropdown_search']))
foreach ($context['additional_dropdown_search'] as $name => $engine)
echo '
<option value="', $name, '">', $engine['name'], '</option>';

echo '
<option value="members"', ($selected == 'members' ? ' selected="selected"' : ''), '>', $txt['search_members'], ' </option>
</select>
</label>';
}

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_topic' : 'topic'), '" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_brd[' : 'brd['), $context['current_board'], ']"', ' value="', $context['current_board'], '" />';

echo '
<input type="submit" name="search;sa=results" value="', $txt['search'], '" class="button_submit', (!empty($modSettings['search_dropdown'])) ? ' with_select' : '', '" />
<input type="hidden" name="advanced" value="0" />
</form>';
}

Not too sure if has to be done template wise, or css wise, so figured I'd ask. :)

Re: Move Quick Login to under linktree

Reply #1

Code: [Select]
<?php

function swap_quicklogin()
{
global $context;

// Let's have a look if the login bar is actually added to the template, if not... nothing to do.
$index = array_search('login_bar', $context['theme_header_callbacks']);
if ($index !== false)
{
// We have the log in bar... throw it away, we don't want it there!
unset($context['theme_header_callbacks']);

// Good old layers to the rescue! A new one added after body (above)
Template_Layers::getInstance()->addAfter('swap_quicklogin', 'body');
}
}

// Wrapper function, called as layer and just calling the original quick login template for rendering.
function template_swap_quicklogin_above()
{
template_th_login_bar();
}

and you can "attach" the swap_quicklogin function to the integrate_load_theme hook, that means:
1) save the code above into a file... for example SwapQuickLogin.subs.php,
2) put the file in sources/subs/
3) run this script once to "install" it:
Code: [Select]
<?php

require_once('SSI.php');
add_integration_function('integrate_load_theme', 'swap_quicklogin', 'SUBSDIR/SwapQuickLogin.subs.php');

and when you will want to revert it, either delete the SwapQuickLogin.subs.php or remove the file and run this script to clean up:
Code: [Select]
<?php

require_once('SSI.php');
remove_integration_function('integrate_load_theme', 'swap_quicklogin', 'SUBSDIR/SwapQuickLogin.subs.php');

Usual disclaimer applies: I have not tested it, so it may be badly broken... I would be surprised otherwise. xD
Bugs creator.
Features destroyer.
Template killer.

Re: Move Quick Login to under linktree

Reply #2

@emanuele, Thank you, but I'd more likely mess that up worse, than your usual disclaimer...LOL
I removed the block of coding, and added the quick login form to a portal block that will always be seen by guests, even on mobile devices. Since never liked the search there, removed it, too. XD

No errors in the log after, so I guess that's good. LOL

Re: Move Quick Login to under linktree

Reply #3

Up to you.
The way I proposed doesn't require edit core files (nor custom themes) and enforces the changes on any new theme you will ever install, yours will have to be repeated if you want pick a new theme.
But of course it's just a minor nuisance. :P
Bugs creator.
Features destroyer.
Template killer.

Re: Move Quick Login to under linktree

Reply #4

Quote from: emanuele – Up to you.
The way I proposed doesn't require edit core files (nor custom themes) and enforces the changes on any new theme you will ever install, yours will have to be repeated if you want pick a new theme.
But of course it's just a minor nuisance. :P


Funny thing is, it was only one theme it was an issue on.
The others, it looked fine...LOL

So, this way, keeps it the same on the other themes, and removes it from the one. :)

Spoiler (click to show/hide)

Re: Move Quick Login to under linktree

Reply #5

Or you can hide it with display none.