<img src="print icon of your choice" /> <a href="index.php?id=95&print=[*id*]">printer friendly format</a>
$print = $_GET['print']; $sql = "SELECT id, longtitle, content, createdon FROM (insert your database info here) a WHERE a.type = 'document' AND a.isfolder = '0' and a.deleted = '0' and a.id = $print LIMIT 1"; $getall = $modx->db->query($sql); if ($getall){ while ($row = $etomite->fetchRow($getall)) { $output .= "<div class='entry'><h3>".$row['longtitle']."</h3>"; $output .= "<div class='entrybody'>".$row['content']."<br></div>"; $output .= "<div class='author'>".strftime("%B %e, %Y", $row['createdon']). "</div>"; $output .= "</div>"; } } return $output;
<img src="print icon of your choice" alt="print page" /> <a href="[~95~]&print=[*id*]">printer friendly format</a>
And it would be more "MODx" to do:
<img src="print icon of your choice" alt="print page" /> <a href="[~95~]&print=[*id*]">printer friendly format</a>
Although it would be best of all to simply provide an alternate CSS file for media="print" in your individual articles template
http://www.alistapart.com/stories/goingtoprint/
[~95~]
// if friendly urls or not $furls = $modx->config['friendly_urls']; $char = $furls ? '?' : '&';
$theLink = '<a href="[~95~]'.$char.'print=[*id*]">printer friendly format</a>';
I really like modx, I’m having a lot of fun digging into it. I think I started using these sql queries because in some of my menus and blog-type story retrieval I wanted to get all stories from almost all folders, but exclude a few. Maybe there’s a better way to do this?
Maybe it’s the way I set things up. I made a topics folder then I set up a different parent folder for each topic under the topics folder. And then on the front page I want to be able to retrieve all those topic folders no matter how many I add, but I don’t want to display folders and I don’t want to display any documents from other folders.
I’m thinking of adding another table for topic categories, and a topic field in the site_content table to avoid making folders altogether and just put everything in the topics folder and select by that topic field.
$modx->db->select( "id, pagetitle", $table, "isfolder = 0 AND template = 10", "createdon DESC", "$L");
One thing to keep in mind (which thing bit me in the backside recently) is that the basic parser evaluation of that [~95~] is to "index.php?id=95". In that case, your added query string argument needs to be &print=whatever, since the ? is already being used for the MODx generated link. But if the site is using friendly URLS, it will want to be ?print=whatever. There’s a bit of nice code that’s good to plug into any snippet you make that will be adding to the query string:
$modx->config['friendly_urls']
$modx->getConfig('site_name');
echo "<pre>"; print_r($modx->config); echo "</pre>"; exit();