Displays a box for users first new to the site, and a option to ignore and make disappear. Opens room for a good introduction for users to explain way around the site, what does what, how why whatever.
Works for me greatly, using existing code but updated a bit.
Open index.php and find:
And add under:
Add to /backend/config.php
Open /backend/functions.php and add:
Now open /themes/default/header.php and find:
And add this after:
Lastly, execute this SQL query:
Thats it! Users will have the option of selecting a theme, language, any custom "tutorial walkthrough" or similar, giving the member a choice to skip it too. This was necessary for a lot of things I have going on.
** NOTE: You may want to replace /images/index_wizard_bg.png [color=rgb(226, 80, 65)]with your own background image or colour[color=rgb(239, 239, 239)].[/color][/color]
** NOTE: Take this code and strip the HTML for your own use.
** NOTE: I personally use the improved is_string function is_string_improved with better string checking and security. You can use PHP's is_string all the same.
Over time I want to add actual walkthroughs for the torrent process / site navigation reason, being a real wizard.
What it looks like on my end:
[ATTACH type="full" width="966px" alt="NewIndexWizard.png"]5420[/ATTACH]
** ENABLING themes in TT, allowing you to actually switch back and forth with mod above, managing the rest in admincp.php (adding theme to db).
open /themes/default/header.php and add at the very top of file:
Then find this:
And replace with this:
The code above must be in every header.php file in ALL themes, for switching to work across. Works perfectly on my site ;)
Optional: allow members to see the current theme colour in account.php (selection):
In account.php find this:
And replace with this:
Add this to every theme.css (every theme). Be sure to update background for each file:
[ATTACH type="full" width="523px" alt="Account-Theme-Color.png"]5421[/ATTACH]
[ATTACH type="full" width="523px" alt="Account-Theme-Color2.png"]5422[/ATTACH]
This tutorial assumes [url='https://www.php.net/manual/en/ini.core.php#ini.short-open-tag']short_open_tag[/url] = On (I use short open tags strictly)
Works for me greatly, using existing code but updated a bit.
Open index.php and find:
stdhead(T_("HOME"));And add under:
// User hide welcome wizard - April 3, 2020
// is_string_improved() - Improved string checking function
if ($CURUSER && is_string_improved($_REQUEST["hidewizard"])) {
SQL_Query_exec("UPDATE users SET hidewizard='yes' WHERE id=$CURUSER[id]");
// Redirect to YOURSITE.com/?lc - "last chance" undo action - April 4, 2020
header("Location: https://YOURSITE.com/?lc");
exit();
}elseif ($CURUSER && is_string_improved($_REQUEST["showizard"])) {
SQL_Query_exec("UPDATE users SET hidewizard='no' WHERE id=$CURUSER[id]");
header("Location: https://YOURSITE.com/");
exit();
}
Add to /backend/config.php
$site_config['theme_cache'] = false; // Enable/Disable CSS caching in browsers. MUST for updating theme files
$site_config['default_theme_name'] = "default";
Open /backend/functions.php and add:
// Improved string checking - Security
function is_string_improved($text) {
return (is_string($text) || (is_object($text) && method_exists($text, '__toString' )));
}Now open /themes/default/header.php and find:
<table width='100%' border='0' cellspacing='10' cellpadding='0'>
<tr>
<td valign='top'>
<!-- START MAIN COLUM -->
And add this after:
<!-- BEGIN New Welcome User Wizard: Themes, Language -->
<?
// User welcome wizard - April 3, 2020
// Detect ?lc query string - "last chance" - restore update notification? - April 4, 2020
if (isset($_GET['lc'])) {
echo "<div>Site wizard has been hidden. <a href='" . $site_config["SITEURL"] . "/?shownotif'>Undo?</a></div>";
}
if (stripos($_SERVER['PHP_SELF'],'index.php') && $CURUSER["skipwizard"] == "no") {
$ss_r = SQL_Query_exec("SELECT * FROM stylesheets");
$ss_sa = array();
while ($ss_a = mysql_fetch_assoc($ss_r)) {
$ss_id = $ss_a["id"];
$ss_name = $ss_a["name"];
$ss_sa[$ss_name] = $ss_id;
}
ksort($ss_sa);
reset($ss_sa);
while (list($ss_name, $ss_id) = each($ss_sa)) {
if ($ss_id == $CURUSER["stylesheet"])
$ss = " selected='selected'";
else
$ss = "";
$stylesheets .= "<option value='$ss_id'$ss>$ss_name</option>\n";
}
$lang_r = SQL_Query_exec("SELECT * FROM languages");
$lang_sa = array();
while ($lang_a = mysql_fetch_assoc($lang_r)) {
$lang_id = $lang_a["id"];
$lang_name = $lang_a["name"];
$lang_sa[$lang_name] = $lang_id;
}
ksort($lang_sa);
reset($lang_sa);
while (list($lang_name, $lang_id) = each($lang_sa)) {
if ($lang_id == $CURUSER["language"])
$lang = " selected='selected'";
else
$lang = "";
$languages .= "<option value='$lang_id'$lang>$lang_name</option>\n";
}
?>
<div style="margin-left:13px;margin-top:25px;max-width:724px">
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card responsive-img" style="height:168px;background:url(/images/index_wizard_bg.png) no-repeat center;">
<div style="color:#FFF;margin-top:-30px">
<h2 style="border-top:none">
<img src="/<? echo $CURUSER["avatar"]; ?>" border="0" style="width:55px;height:55px;border-radius:50%;vertical-align:bottom;padding-right:5px" /> Welcome, <? echo $CURUSER["username"]; ?>!
</h2>
</div>
<span style="padding-left:25px;color:#FFF;font-size:15px"><b>April</b> Update: You now have <b>Themes</b> & <b>Languages</b>. You can now theme YourSite to your liking.</span>
<form name="skip" method="post" action="?skipwizard" onsubmit="return validate();"></form>
<form method="post" name="wizard" action="<? echo $site_config[" SITEURL "]; ?>/take-theme.php" onsubmit="return validate();">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="responsive-table">
<tr>
<td style="float:left;padding-left:20px">
<select name="stylesheet" style="width:180px;height:35px">
<? echo $stylesheets; ?>
</select>
<select name="language" style="width:180px;height:35px">
<? echo $languages; ?>
</select>
</td>
<td style="float:right;padding-right:20px">
<button class="btn btn-danger" onclick="document.forms.wizard.submit();">Set</button>
<button class="btn btn-danger" onclick="document.forms.skip.submit(); alert('You can update these in Account > Settings at any time.');">Skip</button>
</td>
</tr>
</table>
</form>
</article>
</div>
<!-- END New Welcome User Wizard: Themes, Language -->
<? } // End theme/lang ?>
Lastly, execute this SQL query:
ALTER TABLE users
ADD COLUMN skipwizard ENUM('yes','no') NOT NULL default 'no'Thats it! Users will have the option of selecting a theme, language, any custom "tutorial walkthrough" or similar, giving the member a choice to skip it too. This was necessary for a lot of things I have going on.
** NOTE: You may want to replace /images/index_wizard_bg.png [color=rgb(226, 80, 65)]with your own background image or colour[color=rgb(239, 239, 239)].[/color][/color]
** NOTE: Take this code and strip the HTML for your own use.
** NOTE: I personally use the improved is_string function is_string_improved with better string checking and security. You can use PHP's is_string all the same.
Over time I want to add actual walkthroughs for the torrent process / site navigation reason, being a real wizard.
What it looks like on my end:
[ATTACH type="full" width="966px" alt="NewIndexWizard.png"]5420[/ATTACH]
** ENABLING themes in TT, allowing you to actually switch back and forth with mod above, managing the rest in admincp.php (adding theme to db).
open /themes/default/header.php and add at the very top of file:
<?
if ($CURUSER) {
$name = mysql_fetch_assoc(SQL_Query_exec("SELECT uri FROM stylesheets WHERE id='" . ( $CURUSER ? $CURUSER['stylesheet'] : $site_config['default_theme'] ) . "'"));
$theme = $name['uri']; // signed in, retrieve theme name, or use default
if ($site_config['theme_cache'])
$cache = "?v=".rand(); // Prevents browsers caching CSS files
}else{
$theme = $site_config['default_theme_name']; // not signed in, always 'default'
}
?>
Then find this:
<link rel="stylesheet" type="text/css" href="<?php echo $site_config["SITEURL"]; ?>/themes/default/theme.css" />And replace with this:
<link rel="stylesheet" href="<? echo $site_config["SITEURL"] . "/themes/" . $theme . "/theme.css" . $cache; ?>">The code above must be in every header.php file in ALL themes, for switching to work across. Works perfectly on my site ;)
Optional: allow members to see the current theme colour in account.php (selection):
In account.php find this:
print("<div class='profile-stats'>
<ul>
<li><span><font><font>Themes</font></font></span><font><font><select name='stylesheet'>\n$stylesheets\n</select></font></font></a></li>
<li><span><font><font>Preferred Client</font></font></span><font><font><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($CURUSER["client"]) . "\" /></font></font></a></li>
<li><span><font><font>Age</font></font></span><font><font><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($CURUSER["age"]) . "\" /></font></font></a></li>
</ul>
<div class='clear'></div>
</div>");And replace with this:
print("<div class='profile-stats'>
<ul>
<li><span class='current-theme'><font><font>Themes</font></font></span><font><font><select name='stylesheet'>\n$stylesheets\n</select></font></font></a></li>
<li><span><font><font>Preferred Client</font></font></span><font><font><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($CURUSER["client"]) . "\" /></font></font></a></li>
<li><span><font><font>Age</font></font></span><font><font><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($CURUSER["age"]) . "\" /></font></font></a></li>
</ul>
<div class='clear'></div>
</div>");Add this to every theme.css (every theme). Be sure to update background for each file:
.current-theme select {
background: rgba(38, 111, 48, 1); color: rgba(255, 255, 255, 1); height: 35px
}[ATTACH type="full" width="523px" alt="Account-Theme-Color.png"]5421[/ATTACH]
[ATTACH type="full" width="523px" alt="Account-Theme-Color2.png"]5422[/ATTACH]
This tutorial assumes [url='https://www.php.net/manual/en/ini.core.php#ini.short-open-tag']short_open_tag[/url] = On (I use short open tags strictly)