Page 1 of 1

Content 2 PDF

Posted: Sun 1. Oct 2006, 17:18
by Jan212
Hello Peops,

while visiting Pappnases FAQ Site faq.phpwcms-docu.de i noticed the function to create a PDF from the content. Great.

I think this would be a nice feature for phpwcms too. If anybody is interessted to code it feel free to realize this idea and give it to the community.

For the 1st version it would be enough to include only the contentparts text and text with image i think. In later Versions we could think about selected, partial including of the standard content parts.

Posted: Sun 1. Oct 2006, 21:52
by jscholtysik
Hi Jan,


in earlier days I already asked OG to include such thing into phpwcms. He answered me that it wouldn't be that important... :-(

But Markus Köhl (markoehl) said that he is developing something like that for a customer. Perhaps you can ask him again... ;-)

BTW: I already made a feature request on SourceForge 4 weeks ago for the PDF feature...


Joachim

Posted: Sun 1. Oct 2006, 23:15
by kubens
I developed a solution based on fpdf for one of my travel sites. Unfortunatelly it is based on a customized content part which contains a set of fields. This makes it easy to render the content properly. But unfortunatelly I haven't any solution for the rest :-( So I would very interested in this issue too ;-)

May this could be done by an RT :?

Br
Wolfgang

Posted: Mon 2. Oct 2006, 07:18
by sustia
Hi, I've implemented this with html2pdf.
You must just put a link in the template section, not intrusive and easy to install.

You can see here in action

http://noria.ba.cnr.it/farm.phtml

Posted: Mon 2. Oct 2006, 13:25
by Jan212
Hello,

@sustia - nice solution, thanks for your reply, but i would like it more to see this implemented inside phpwcms as a mod. i also don't like the dialogue before creating the pdf, even it's wise for some printers.

@kubens - maybe you could give us more details about customizing the content parts set/fields and put the fpdf based solution files as a base for development on your webspace for downloading.

Posted: Mon 2. Oct 2006, 15:03
by phalancs
If anybody is interessted to code it feel free to realize this idea and give it to the community.
Hmm sounds pretty funny/ sarcastic ;)
Usually it reads somehow like this:
If anybody is interessted to use it feel free to download this idea which is a gift to the community.
Although in every thread about this they say its easy, I think there has never been a release yet.

Posted: Mon 2. Oct 2006, 15:15
by Jan212
Kannst du mir das mal in Landessprache ;) erklären was du meinst??? Werde nicht ganz schlau aus deinem Posting...

Posted: Mon 2. Oct 2006, 22:18
by kubens
Hi Jan22,

I made some modifications in the past on 1.2.6. Unfortunately I was so busy in the past that I was not able to migrate this to 1.2.8. I think that this wont work in 1.2.8 without any modifications. As far as I have seen OG made some enhancements on content parts. May anybody is interested to test this in 1.2.8 ;-)

Please find below a list of files which are required to implement a custom content part. As far as I can remember I just modified one original file to make the custom content part available inside backend.

Custom Content Part:

Image
Image

file: include/inc_cntpart/inc_lang/de/cnt9001.inc.php

Code: Select all

<?php

  $CNT9001['cnt9001_land']                    = 'Land';
  $CNT9001['cnt9001_region']                  = 'Region';
  $CNT9001['cnt9001_hotel']                   = 'Hotel';
  $CNT9001['cnt9001_kategorie']               = 'Kategorie';
  $CNT9001['cnt9001_leistung_1wo']            = 'Leistung';
  $CNT9001['cnt9001_leistung_2wo']            = 'Leistung';
  $CNT9001['cnt9001_preis_1wo']               = 'Preis';
  $CNT9001['cnt9001_preis_2wo']               = 'Preis';
  $CNT9001['cnt9001_kurzbeschreibung']        = 'Kurzbeschreibung';
  $CNT9001['cnt9001_lage'] 			              = 'Lage';
  $CNT9001['cnt9001_anlage'] 		              = 'Anlage';
  $CNT9001['cnt9001_zimmer_standard']         = 'Standardzimmer';
  $CNT9001['cnt9001_zimmer_familie'] 			    = 'Familienzimmer';
  $CNT9001['cnt9001_zimmer_suite'] 			      = 'Suite';
  $CNT9001['cnt9001_verpflegung'] 			      = 'Verpflegung';
  $CNT9001['cnt9001_unterhaltung'] 			      = 'Unterhaltung';
  $CNT9001['cnt9001_kinder'] 			            = 'Kinder';
  $CNT9001['cnt9001_strand'] 			            = 'Strand';
  $CNT9001['cnt9001_sport_inkl'] 			        = 'Sport ohne Gebühr';
  $CNT9001['cnt9001_sport_exkl'] 			        = 'Sport gegen Gebühr';
  $CNT9001['cnt9001_leistung_inkl'] 			    = 'Leistungen Inklusive';
  $CNT9001['cnt9001_leistung_exkl'] 			    = 'Leistungen gegen Gebühr';
  $CNT9001['cnt9001_traveltainment_iff']      = 'Traveltainment Hotel-ID';
  $CNT9001['cnt9001_traveltainment_agent']    = 'Traveltainment Agent';

?>
file: include/inc_front/content/cnt9001.article.inc.php

Code: Select all

<?php

  require_once ('include/inc_cntpart/inc_lang/de/cnt9001.inc.php');
  $html =<<<EOF_HTML
  {article_cid}<br>
  {article_id}<br>
  {cnt9001_land}<br>
  {cnt9001_region}<br>
  {cnt9001_hotel}<br>
  EOF_HTML;
  
  // replace values from content
  if($crow["acontent_text"]) {
    $aValue = unserialize($crow["acontent_text"]);
  }
  
  // load article
  $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_id=".$crow['acontent_aid'];
  if($result = mysql_query($sql)) {
    if ($row = mysql_fetch_assoc($result)) {
      $article = $row;
    }
    mysql_free_result($result);
  }
  
  // replace placeholder from content part
  foreach ($aValue as $key => $value) {
    $html = str_replace('{'.$key.'}',$aValue[$key],$html);
    $GLOBALS['content']['articles'][$GLOBALS['content']['article_id']][$key]=$value;
  }
  
  // replace placeholder from article
  foreach ($article as $key => $value) {
    $html = str_replace('{'.$key.'}',$article[$key],$html);
  }
  
  $CNT_TMP .= $html;

?>
file: include/inc_lib/content/cnt9001.readform.inc.php

Code: Select all

<?php

  require_once ('include/inc_cntpart/inc_lang/de/cnt9001.inc.php');
  foreach ($CNT9001 as $key => $value) {
    $content[$key] = isset($_POST[$key]) ? html_specialchars(slweg($_POST[$key])) : '';
  }

?>
file: include/inc_lib/content/cnt9001.sql.inc.php

Code: Select all

<?php

  require_once ('include/inc_cntpart/inc_lang/de/cnt9001.inc.php');
  $aValue = array();
  foreach ($CNT9001 as $key => $value) {
    $aValue[$key] = $content[$key];
  }
  
  $SQL .= "acontent_text = '".serialize($aValue)."', acontent_html = '".$aValue['cnt9001_alias']."' ";

?>
file: include/inc_lib/content/cnt9001.takeval.inc.php

Code: Select all

<?php

  $aValue = unserialize($row["acontent_text"]);
  
  foreach ($aValue as $key => $value) {
    $content[$key] = $value;
  }

?>
file: include/inc_lib/article.contenttype.inc.php

Code: Select all

<?php

  $wcs_content_type = array(
  	 0 => $BL['be_ctype_plaintext'] ,
  	 6 => $BL['be_ctype_html']
     // 
     // ...
     //
  );

  $wcs_content_type["9001"] = 'Hotelinformationen';

?>
file: include/inc_tmpl/content/cnt9001.inc.php

Code: Select all

<?php

  // load default 
  require_once ('include/inc_cntpart/inc_lang/de/cnt9001.inc.php');
  
  
  // fetch information from article
  $sql = "select * from ".DB_PREPEND."phpwcms_article where article_id='".$article["article_id"]."' LIMIT 1;";
  if($result = mysql_query($sql, $db) or die("error getting info about article")) {
  	if($row = mysql_fetch_assoc($result)) {
  		$default["category_id"]	= $row["article_cid"];
  		$default["hotel"]		    = $row["article_title"];
  	}
  }
  // fetch information from category
  $sql = "select * from ".DB_PREPEND."phpwcms_articlecat where acat_id='".$default["category_id"]."' LIMIT 1;";
  if($result = mysql_query($sql, $db) or die("error getting info about article")) {
  	if($row = mysql_fetch_assoc($result)) {
  		$default["structid"]    = $row["acat_struct"];
  		$default["region"]      = $row["acat_name"];
  		$default["alias"]       = $row["acat_alias"] . strtolower(remove_accents($default["hotel"])) . "/";
  	}
  }
  
  // fetch information from structure
  $sql = "select * from ".DB_PREPEND."phpwcms_articlecat where acat_id='".$default["structid"]."' LIMIT 1;";
  if($result = mysql_query($sql, $db) or die("error getting info about article")) {
  	if($row = mysql_fetch_assoc($result)) {
  		$default["land"] = $row["acat_name"];
  	}
  }
  
  // fetch information from content
  $default["article_id"] = $article["article_id"];
  $default["cnt9001_preis_info"] = "";

?>

<tr bgcolor="#F3F5F8">
	<td align="right" valign="top" class="chatlist">&nbsp;</td>
	<td valign="top"><div class="chatlist"><?php echo $CNT9001['cnt9001_traveltainment_iff'] ?>:</div><input name="cnt9001_traveltainment_iff" id="cnt9001_traveltainment_iff" type="text" class="f11b"  style="width: 440px" value="<?= isset($content["cnt9001_traveltainment_iff"]) ? $content["cnt9001_traveltainment_iff"] : $default["traveltainment_iff"] ?>"></td>
</tr>
<tr bgcolor="#F3F5F8">
	<td align="right" valign="top" class="chatlist">&nbsp;</td>
	<td valign="top"><div class="chatlist"><?php echo $CNT9001['cnt9001_land'] ?>:</div><input name="cnt9001_land" id="cnt9001_land" type="text" class="f11b"  style="width: 410px" value="<?= isset($content["cnt9001_land"]) ? $content["cnt9001_land"] : $default["land"] ?>"><input type="button"  class="button10" value="..." onClick="this.form.cnt9001_land.value='<?= $default["land"] ?>'"></td>
</tr>
<tr bgcolor="#F3F5F8">
	<td align="right" valign="top" class="chatlist">&nbsp;</td>
	<td valign="top"><div class="chatlist"><?php echo $CNT9001['cnt9001_region'] ?>:</div><input name="cnt9001_region" id="cnt9001_region" type="text" class="f11b"  style="width: 410px" value="<?= isset($content["cnt9001_region"]) ? $content["cnt9001_region"] : $default["region"] ?>"><input type="button"  class="button10" value="..." onClick="this.form.cnt9001_region.value='<?= $default["region"] ?>'"></td>
</tr>
<tr bgcolor="#F3F5F8">
	<td align="right" valign="top" class="chatlist">&nbsp;</td>
	<td valign="top"><div class="chatlist"><?php echo $CNT9001['cnt9001_hotel'] ?>:</div><input name="cnt9001_hotel" id="cnt9001_hotel" type="text" class="f11b"  style="width: 410px" value="<?= isset($content["cnt9001_hotel"]) ? $content["cnt9001_hotel"] : $default["hotel"] ?>"><input type="button"  class="button10" value="..." onClick="this.form.cnt9001_hotel.value='<?= $default["hotel"] ?>'"><br></td>
</tr>
<tr bgcolor="#F3F5F8">
	<td align="right" valign="top" class="chatlist">&nbsp;</td>
	<td valign="top"><div class="chatlist"><?php echo $CNT9001['cnt9001_kategorie'] ?>:</div><select name="cnt9001_kategorie" id="cnt9001_kategorie" class="f11b" style="width: 440px"><option value="3"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "3" ? ' selected' : '' ?>>3</option><option value="35"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "35" ? ' selected' : '' ?>>3+</option><option value="4"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "4" ? ' selected' : '' ?>>4</option><option value="45"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "45" ? ' selected' : '' ?>>4+</option><option value="5"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "5" ? ' selected' : '' ?>>5</option><option value="55"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "55" ? ' selected' : '' ?>>5+</option> <option value="6"<?= isset($content["cnt9001_kategorie"]) && $content["cnt9001_kategorie"] == "6" ? ' selected' : '' ?>>6</option></select></td>
</tr>

<!-- ... -->

file: include/inc_tmpl/content/cnt9001.list.inc.php

Code: Select all

<?php

  $cinfo[1] = html_specialchars(cut_string($row["acontent_title"],"…", 55));
  $cinfo[2] = html_specialchars(cut_string($row["acontent_subtitle"],"…", 55));
  $cinfo[2] = "";
  $cinfo["result"] = "";
  
  foreach($cinfo as $value) {
   if($value) $cinfo["result"] .= $value."\n";
  }
  $cinfo["result"] = str_replace("\n", " / ", chop($cinfo["result"]));
  if($cinfo["result"]) { //Zeige Inhaltinfo
   echo "<tr><td>&nbsp;</td><td class=\"v10\">";
   echo "<a href=\"phpwcms.php?do=articles&p=2&s=1&aktion=2&id=".$article["article_id"]."&acid=".$row["acontent_id"]."\">";
   echo $cinfo["result"]."</a></td><td>&nbsp;</td></tr>";
  }

?>
Some words at the end of this. Don't ask me for more details. I made this some months ago and before I spent time in this, I would invest time in 1.2.8 ;-)

Br
Wolfgang

Posted: Sat 21. Oct 2006, 15:55
by kubens
Just to keep each other updated. I checked this under 1.2.8 and it seems to work :D

Posted: Mon 30. Oct 2006, 22:43
by Jan212
Hi Kubens,

hmm, der von dir gepostete Code hat doch nix mit der PDF Sache zu tun oder war das jetzt ein Missverständnis oder bin ich wieder zu blind?

VG - Jan

Posted: Tue 31. Oct 2006, 09:06
by kubens
Hi Jan,

you are right the customized contentpart does not consider directly the pdf issue :-( But for this I have created a php prog which could extract the content from the phpWCMS database and pending on the contentpart I load a template file which is responsible for the pdf layout of this contenpart. This concept is similar to the phpWCMS concept. But unfortunatelly this is not integrated into phpWCMS. May anytime we will see such a feature inside phpWCMS.

Br
Wolfgang