Notifications
Clear all

[Tutorial] Adding icons to Panels

4 Posts
2 Users
0 Reactions
5,202 Views
(@jacynthe)
Posts: 242
Estimable Member
Topic starter
 

NOTE
This is somewhat related to the following topic ( https://efiction.org/forums/index.php?topic=5447.0) so admins should feel free to delete previous said topic in favor of this tutorial if they so choose.

Working Example: http://fanfics.suethomasfbeye.net/toplists.php (but also the member account menu if you are logged in).

The Tutorial in itself
This skinning mod requires a database alteration, so before you do anything... remember to back up your database. That way, you can always go back if you make a mistake.

Step 1
In phpMyAdmin, select your efiction database. Click on Query and enter this in the SQL Query area:

ALTER TABLE 'fanfiction_panels' ADD `panel_image` VARCHAR(100) NULL null AFTER `panel_url`;

Step 2 - for the member account menu
In your efiction install, open user.php and look for

if(!$panel['panel_url']) $output .=  "<a href=""user.php?action=".$panel['panel_name'"]."">".$panel['panel_title']."</a><br />n";
else $output .= "<a href=""".$panel['panel_url'"]."">".$panel['panel_title']."</a><br />n";
}

replace with

if(!$panel['panel_url']) $output .=  "".$panel['panel_image']." <a href=""user.php?action=".$panel['panel_name'"]."">".$panel['panel_title']."</a><br />n";
else $output .= "".$panel['panel_image']." <a href=""".$panel['panel_url'"]."">".$panel['panel_title']."</a><br />n";
}

Step 2 - for the Top Ten Lists
In your efiction install, open toplists.php and look for

$output .= "<a href="'toplists.php?list=".$l['panel_name'"]."'>".$l['panel_title']."</a><br />";

replace with

$output .= "".$l['panel_image']." <a href="'toplists.php?list=".$l['panel_name'"]."'>".$l['panel_title']."</a><br />";

Step 3
Open admin/panels.php and look for

if(!empty($_GET['edit'])) {
if(!empty($_POST['submit'])) {
$panel_name = addslashes(strip_tags(descript($_POST['panel_name'])));
$panel_title = addslashes(strip_tags(descript($_POST['panel_title'])));
$panel_url = addslashes(strip_tags(descript($_POST['panel_url'])));
$panel_level = (!empty($_POST['panel_level']) && isNumber($_POST['panel_level']) ? $_POST['panel_level'] : 0);
$panel_hidden = (!empty($_POST['panel_hidden']) ? 1 : 0);
$panel_type = strip_tags(descript($_POST['panel_type']));

replace with

if(!empty($_GET['edit'])) {
if(!empty($_POST['submit'])) {
$panel_name = addslashes(strip_tags(descript($_POST['panel_name'])));
$panel_title = addslashes(strip_tags(descript($_POST['panel_title'])));
$panel_url = addslashes(strip_tags(descript($_POST['panel_url'])));
$panel_image = addslashes(descript($_POST['panel_image']));
$panel_level = (!empty($_POST['panel_level']) && isNumber($_POST['panel_level']) ? $_POST['panel_level'] : 0);
$panel_hidden = (!empty($_POST['panel_hidden']) ? 1 : 0);
$panel_type = strip_tags(descript($_POST['panel_type']));

look for

if($_GET['edit'] != "new") $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_panels SET panel_name = '$panel_name', panel_title = '$panel_title', panel_url = '$panel_url', panel_level = '$panel_level', panel_hidden = '$panel_hidden', panel_type = '$panel_type'".(!empty($panel_hidden) ? ", panel_order = '$nextorder'" : "")." WHERE panel_id = '".$_GET['edit']."'");
else $result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_panels(`panel_name`, `panel_title`, `panel_url`, 'panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( '$panel_name', '$panel_title', '$panel_url', ''$panel_level', '$panel_hidden', '$panel_type', '$nextorder')");

replace with

if($_GET['edit'] != "new") $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_panels SET panel_name = '$panel_name', panel_title = '$panel_title', panel_url = '$panel_url', panel_image = '$panel_image', panel_level = '$panel_level', panel_hidden = '$panel_hidden', panel_type = '$panel_type'".(!empty($panel_hidden) ? ", panel_order = '$nextorder'" : "")." WHERE panel_id = '".$_GET['edit']."'");
else $result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_panels(`panel_name`, `panel_title`, `panel_url`, `panel_image`, `panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( '$panel_name', '$panel_title', '$panel_url', '$panel_image', '$panel_level', '$panel_hidden', '$panel_type', '$nextorder')");

look for

<label for='panel_url'>"._PANELURL.":</label> <input type='text' class='textbox' name='panel_url' id='panel_url' value='".$panelinfo['panel_url']."'><br />

add after it

<label for='panel_image'>Panel icon:</label> <input type='text' class='textbox' name='panel_image' id='panel_image' value='".$panelinfo['panel_image']."'><br />

Step 4
Log into your efiction library and move to the admin console. Click on the Panels link and choose the panel you wish to add an image for. In the panel icon field, enter something like this

<img src=""images/name_of_file.gif"" border="0">&nbsp;

* Please note that this location means the images would be in the images folder of your efiction install, not in the images folder of the skins you are using. So Edit accordingly if you wish to have different icons on different skins.

Remember that the Top Ten Lists panels all have the Type L, most the Member Account menu are Type U, and the Stories/Series panels are Type P (the manage images - if you have images upload enabled - is a Type S panel).


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 10/09/2007 7:43 pm
(@tammy)
Posts: 2577
Member Moderator
 

Just a suggestion, but I would set it up like the category images so that you could have images based on your theme.  And also check that the image exists before inserting it into the code that way non-existent images don't show up as broken.


 
Posted : 13/09/2007 1:13 am
(@jacynthe)
Posts: 242
Estimable Member
Topic starter
 

Yeah that's a good idea. Personally, I prefer to use the same images independtly of the skin, but I'm sure some - if not most people - would prefer having different sets of icons for different skins. I'll have to tinker with that later then and look at the way you got the images in the categories..

Thanks Tammy.


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 13/09/2007 9:05 am
(@tammy)
Posts: 2577
Member Moderator
 

Well it's hard to get the anti-aliasing right to use the same image on a dark and a light theme.


 
Posted : 13/09/2007 9:42 am
Share: