Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 04-13-2009, 06:55 PM
Blog Master Offline
forum loafer
 
Join Date: Dec 2008
Posts: 11
About Page Addon

Okay... I call it a "SpotLight" page, but it serves the same function. I see people post on here all the time asking how to update their About pages. Its usually people with very little HTML knowledge. So, I am trying to write my first addon to make this work in the admin screen. I have gotten far enough to create something with its own Tab in the admin screen and all. I just don't know how to make it work with markups. Does anyone want to clean this up a bit?

Quote:
<?PHP
if ($_GET['view']=='addons' && $_GET['spot']=='light') {
$_SESSION['spotlight'] = $_POST['spot'];
}

$addon_name = "<a name=\"APE\"></a>SpotLight";
$addon_version = "1.0";
$addon_description = "This Activates The SpotLight Section";
add_admin_functions('spot_light','info','','');
add_admin_functions('spot_light','options','option s','SpotLight');
add_admin_functions('','admin_main_menu','SpotLigh t','');


@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."spotlighteditor` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`spotlight_editor` TEXT NOT NULL)");


if($_POST['action'] == "update_spotlighteditor") {

### query the spotlight text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."spotlighteditor`");
$spotlighteditor = @mysql_fetch_array($cquery);

### add slashes to special chars like ' and "
$spotlight_editor = addslashes($_POST['spotlight_editor']);

### if there is no id present in the database, we need to use the insert statement
if($spotlighteditor['id'] == '') {

@mysql_query("INSERT INTO `".$pixelpost_db_prefix."spotlighteditor` (`spotlight_editor`) VALUES('".$spotlight_editor."')");
} else { ### if we made it down here, we have an id and we can simply update the current row

@mysql_query("UPDATE `".$pixelpost_db_prefix."spotlighteditor` SET `spotlight_editor` = '".$spotlight_editor."'");
}
}
### query the about text database again and pullout all the rows
$query = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."spotlighteditor`");
$spotlighteditor = @mysql_fetch_array($query);

### remove those slashes we previously added for viewing
$spotlights = $spotlighteditor['spotlight_editor'];
$spotlights = stripslashes($spotlights);



add_admin_functions('spot_light','admin_main_menu_ contents','SpotLight','');
// hey, that is cool!


function spot_light()
{
$html =

<<<EOE

&nbsp;
<form name="spotlighteditoraddon" id="formAPE" method="post" action="#APE">
<input name="action" type="hidden" value="update_spotlighteditor" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;



<div class="jcaption" id="ara">Spotlight Instructions</div><BR>



<b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#006600>(Use the box below to update your 'Info' page. Simply add info using the format in this example.)</font>
</b>
<BR><hr><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;h2&g t;</code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Put Your Title In This Space:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;/h2&gt;</code>
<BR><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;p&gt ;</code>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter a paragraph about yourself here.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;/p&gt;</code>
<BR><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;p&gt ;</code>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add another paragraph if you want to.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;/p&gt;</code>
<BR>


<BR><HR>
<b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#006600>(Repeat This Format For Additional Sections.)</b></font><BR><BR><BR><BR>








<div class="jcaption" id="ara">Spotlight Page</div><BR>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the details for your spotlight page here using the format above:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea name="spotlight_editor" id="spotlight_editor" rows="10" cols="90">



</textarea><br /><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value="Submit" /><BR><BR>
<B><font color=#990000 ></font></b>
</form>
</div>


EOE;

echo $html;
}
### finally, our template tags
$tpl = str_replace("<SPOTLIGHT_PAGE>",$spotlights,$tpl);

?>
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 04:25 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs