archive editable areas
I have an article secton that is populated via powercms. How could I archive that area into a pdf (and retain the css) so users can view the archives later as pdf files.... as my articles will be updated frequently.
I have an article secton that is populated via powercms. How could I archive that area into a pdf (and retain the css) so users can view the archives later as pdf files.... as my articles will be updated frequently.
that is not supported by PowerCMS.
I found another way by just creating a static page from the dynamic page via file_get_contents then writing a new html file. Not ideal for my situation...but close enough for government work ..ha ha
a built in archiving function would be a nice addon for this
I figured I would post my remedy here in case anyone else needs to do something similar
I built a database named archlist with 3 fileds
id - int(11) -auto incr primary
name - varchar 255
dateTime - dateTime
that is so I can save out a path for a link to the archived area
I created a folder named archive
in that folder is a normal page with all the styles and stuff for your page and the developer notes pasted in just like normal...that will act as the template that I'm building off of. I named that page nltemplate.php
When the new static pages are created, they will reside inside that archive folder.
note that you may need to edit the path in the developer notes as this is now a subfolder.
in that archive folder is a basic connect_to_mysql.php script so you can connect to the new table we made for saving the path.
And then this file is also in the archive folder...it's named index.php
I commented it out as best I could
<pre>
<?php
//connect to the database here
include ("connect_to_mysql.php");
//this is so we can rename the new html file with a system to prevent overwriting
//this will name the html dy date...month,day,year,hour,minute,second
$m = date(M);
$d = date(j);
$y = date(y);
$h = date(G);
$min = date(i);
$sec = date(s);
$newname = $m.$d.$y.$h.$min.$sec;
?>
<?php
//seeing if someone hit the submit button on our form
if ($_POST['archiveit'] == "true"){
$archname = $_POST['archname'];
$archname = strip_tags($archname);
$archname = stripslashes($archname);
$archname = mysql_real_escape_string($archname);
//building a link to the new file
$fullpath = '<a target="_blank" href="archive/' . $newname . '.html">' . $archname . '</a>';
if (!$archname){
$msg = "Enter a name";
} else {
//inserting that link into the database
$sql_insert = mysql_query("INSERT INTO archlist (name, dateTime)
VALUES('$fullpath',now() )") or die (mysql_error());
//creating the html from php
//enter your sites url in place
$page=file_get_contents('http://www.yoursite.com/archive/nltemplate.php');
$fp=fopen($newname.'.html','w+');
fputs($fp,$page);
fclose($fp);
}
}
?>
<?php
//this is for deleting archives if you wish
if($_POST['delete']){
if (!empty($_POST['checkbox'])) {
foreach($_POST['checkbox'] as $v) {
$del_id = mysql_real_escape_string($v);
$sql = "DELETE FROM archlist WHERE id ='$del_id'";
mysql_query($sql);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Archive Newsletter</title>
</head>
<body>
<div id="wrap">
<div id="form">
<!-- this form will post back to this page -->
<!-- this form is for the archiving process -->
<form action="index.php" method="post" >
<table width="100%" border="0">
<tr>
<td> </td>
<td>Choose a name for your archived newsletter.<br />
example: July 2010 Newsletter
<br />
<input name="archname" type="text" id="archname" size="50" /><br />
</td>
</tr>
<tr>
<td> </td>
<td><input type="hidden" name="archiveit" id="archiveit" value="true"/>
<input type="submit" name="submit" value="Archive Newsletter" />
<?php echo $msg; ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<form id="form1" name="form1" method="post" action="index.php">
<!-- this form is for the deleting process -->
<table width="100%" border="0">
<tr>
<td width="11%" align="center">#</td>
<td width="89%"><strong>You can delete archived newsletters below.</strong></td>
</tr>
<?php
$sql="SELECT id,name FROM archlist";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>"></td>
<td><?php echo $rows['name']; ?></td>
</tr>
<?php } ?>
<tr>
<td align="center"> </td>
<td><input type="submit" name="delete" id="delete" value="delete" /></td>
</tr>
</table><br /><br />
</form>
</div>
</div>
</body>
</html>
</pre>
all thats left to do is echo out those links that we added to the db wherever you want them to display
<pre>
<?php include ("connect_to_mysql.php"); ?>
<h1>Newsletter Archive </h1>
<?php
$result3 = mysql_query("SELECT name,dateTime FROM archlist ORDER BY dateTime DESC");
$num_rows = mysql_num_rows($result3);
if($num_rows == 0) {
echo "No Newsletters Archived Yet.";
} else {
echo "<table border='0' cellspacing='0' cellpadding='0'>";
while($row3 = mysql_fetch_array( $result3 )) {
echo "<tr><td>";
echo $row3['name'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</pre>
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.