This following customization will display Breadcrumb Links in websites that generated by PHP Report Maker 5.1, as well as the similar customization in PHPMaker 9. Please always refer to that article if you want to implement the Breadcrumb Links in your report pages, since there is some important things that you should know regarding how to create breadcrumblinks table in order to store your Breadcrumb Links records.
This customization is very useful if you are integrating your reports that generated by PHP Report Maker 5.1 with web applications that generated by PHPMaker 9, and you want to synchronize the look and view of your web applications. Just like the customization in PHPMaker, we will also customize PHP Report Maker template files. In other words, we will not modify any generated web files.
[hidepost]
-
Open your \Script\rpt-summary.php file, and find this code:
<!-- top slot --> <a name="top"></a> <!--##=sChartExpEnd##-->
after the last line of that code, please insert the following code:
<?php // Begin of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 ?> <?php if (MS_SHOW_BREADCRUMB_IN_ALL_PAGES) { ?> <span> <div id="ewContainer"> <ul id="breadcrumb"> <?php if (isset($_GET["showmaster"])) { $sSql = "SELECT C.* FROM breadcrumblinks AS B, breadcrumblinks AS C WHERE (B.Lft BETWEEN C.Lft AND C.Rgt) AND (B.Page_URL LIKE '".$_GET["showmaster"]."') ORDER BY C.Lft"; // showmaster, in order to get the full path of the master record!, modified by Masino Sinaga, January 27, 2012 } else { $sSql = "SELECT C.* FROM breadcrumblinks AS B, breadcrumblinks AS C WHERE (B.Lft BETWEEN C.Lft AND C.Rgt) AND (B.Page_URL LIKE '".ew_CurrentPage()."') ORDER BY C.Lft"; } $rs = $conn->Execute($sSql); $recCount = $rs->RecordCount(); $rs->MoveFirst(); $i = 1; while (!$rs->EOF) { if ($i < $recCount) { if ($i==1) { echo "<li><a href='". $rs->fields("Page_URL")."' title='".$ReportLanguage->BreadcrumbPhrase("Home")."'><img src='./phpimages/home.png' alt='".$ReportLanguage->BreadcrumbPhrase("Home")."' class='home' /></a></li>"; } else { echo "<li><a href='". $rs->fields("Page_URL")."'>".$ReportLanguage->BreadcrumbPhrase($rs->fields("Page_Title"))."</a></li>"; } } else { echo "<li>".$ReportLanguage->BreadcrumbPhrase($rs->fields("Page_Title"))."</li>"; } $i++; $rs->MoveNext(); } $rs->Close(); ?> </ul> </div> </span> <?php } ?> <?php // End of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 ?> -
Open your \Script\rpt-crosstab.php file, and find this code:
<!-- Top container (begin) --> <tr><td colspan="3"><div id="ewTop" class="phpreportmaker"> <!-- top slot --> <a name="top"></a> <!--##=sChartExpEnd##-->
after the last line of that code, please insert the following code:
<?php // Begin of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 ?> <?php if (MS_SHOW_BREADCRUMB_IN_ALL_PAGES) { ?> <span> <div id="ewContainer"> <ul id="breadcrumb"> <?php if (isset($_GET["showmaster"])) { $sSql = "SELECT C.* FROM breadcrumblinks AS B, breadcrumblinks AS C WHERE (B.Lft BETWEEN C.Lft AND C.Rgt) AND (B.Page_URL LIKE '".$_GET["showmaster"]."') ORDER BY C.Lft"; // showmaster, in order to get the full path of the master record!, modified by Masino Sinaga, January 27, 2012 } else { $sSql = "SELECT C.* FROM breadcrumblinks AS B, breadcrumblinks AS C WHERE (B.Lft BETWEEN C.Lft AND C.Rgt) AND (B.Page_URL LIKE '".ewrpt_CurrentPage()."') ORDER BY C.Lft"; } $rs = $conn->Execute($sSql); $recCount = $rs->RecordCount(); $rs->MoveFirst(); $i = 1; while (!$rs->EOF) { if ($i < $recCount) { if ($i==1) { echo "<li><a href='". $rs->fields("Page_URL")."' title='".$ReportLanguage->BreadcrumbPhrase("Home")."'><img src='./phpimages/home.png' alt='".$ReportLanguage->BreadcrumbPhrase("Home")."' class='home' /></a></li>"; } else { echo "<li><a href='". $rs->fields("Page_URL")."'>".$ReportLanguage->BreadcrumbPhrase($rs->fields("Page_Title"))."</a></li>"; } } else { echo "<li>".$ReportLanguage->BreadcrumbPhrase($rs->fields("Page_Title"))."</li>"; } $i++; $rs->MoveNext(); } $rs->Close(); ?> </ul> </div> </span> <?php } ?> <?php // End of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 ?> -
Open your \Script\phprptfn.php file, and find this code:
// Get menu phrase function MenuPhrase($MenuId, $Id) {before the first line of that code, please insert the following code:
// Begin of modification Displaying Breadcrumbs in All Pages, by Masino Sinaga, May 25, 2012 // Get breadcrumb phrase function BreadcrumbPhrase($Id) { if (is_object($this->Phrases)) { return $this->GetNodeAtt($this->Phrases->SelectSingleNode("//breadcrumb/phrase[@id='" . ($Id) . "']"), "value"); } elseif (is_array($this->Phrases)) { return ewrpt_ConvertFromUtf8(@$this->Phrases['ew-language']['breadcrumb']['phrase'][($Id)]['attr']['value']); } } // Set breadcrumb phrase function setBreadcrumbPhrase($Id, $Value) { if (is_array($this->Phrases)) { $this->Phrases['ew-language']['breadcrumb']['phrase'][($Id)]['attr']['value'] = $Value; } } // End of modification Displaying Breadcrumbs in All Pages, by Masino Sinaga, May 25, 2012 -
Open your \Script\rpt-userfn.php file, and find this code:
?> <!--##/session##-->
before the first line of that code, please insert the following code:
// Begin of modification Displaying Breadcrumbs in All Pages, by Masino Sinaga, May 25, 2012 function getCurrentReportPageTitle($pt) { global $CurrentPageTitle, $conn, $ReportLanguage; $sSql = "SELECT C.* FROM breadcrumblinks AS B, breadcrumblinks AS C WHERE (B.Lft BETWEEN C.Lft AND C.Rgt) AND (B.Page_URL LIKE '".$pt."') ORDER BY C.Lft"; $rs = $conn->Execute($sSql); $recCount = $rs->RecordCount(); if ($recCount>0) { $rs->MoveFirst(); $i = 1; while (!$rs->EOF) { if ($i < $recCount) { if ($i==1) { // $CurrentPageTitle = 'Home'; // skip this! } else { // $CurrentPageTitle .= " » ". $Language->Phrase($rs->fields("Page_Title")).""; // skip this! } } else { // this is the current page, just display this, no need to display its parent! $CurrentPageTitle .= $ReportLanguage->BreadcrumbPhrase($rs->fields("Page_Title"))."". " « " . $ReportLanguage->ProjectPhrase("BodyTitle"); return; } $i++; $rs->MoveNext(); } $rs->Close(); } else { $CurrentPageTitle = $ReportLanguage->ProjectPhrase("BodyTitle"); } } // End of modification Displaying Breadcrumbs in All Pages, by Masino Sinaga, May 25, 2012 -
Open your \Script\rpt-phpcommon-scripts.php file, and find this code:
// Page main $<!--##=sPageObj##-->->Page_Main(); ?>
after the last line of that code, please insert the following code:
<?php // Begin of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 getCurrentReportPageTitle(ewrpt_CurrentPage()); // End of modification Displaying Breadcrumb Links in All Pages, by Masino Sinaga, May 4, 2012 ?>
-
In order to support for multi language, you have to define/add all phrases that you had in your Page_Title field of breadcrumblinks table into your .xml language files that located in C:\Program Files\PHP Report Maker 5\languages\ folder.
Define all of your breadcrumb links phrases after the following line in your .xml language files:<ew-language date="2011/7/4" version="5.0.0" id="en" name="English" desc="English" author="e.World Technology Ltd.">
For example, one of your phrases in Page_Title field of the breadcrumblinks table is “Customers Report”, so define it into the english.xml file as following (just make the values in id and value are same for the simplicity):
<breadcrumb> <phrase id="Customers List" value="Customer Lists"/> </breadcrumb>Please note that if you want to add the new phrase, then you have to insert it between
<breadcrumb>
and
</breadcrumb>
tags.
- Another important thing that you should know is you have to insert your Breadcrumb Links record into breadcrumblinks table, just like we did for PHPMaker customization. See the first step in that article above.
- Finally, re-generate your script files using PHP Report Maker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.