Skip to content

Commit

Permalink
lucee#7 Outputting links to a page's tagged categories in the 'see al…
Browse files Browse the repository at this point in the history
…so' section of the page layout
  • Loading branch information
DominicWatson committed Apr 26, 2015
1 parent f2247ae commit 493f8d9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
4 changes: 4 additions & 0 deletions api/data/DocTree.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ component accessors=true {
return pathMap[ arguments.path ] ?: NullValue();
}

public boolean function pageExists( required string id ) {
return idMap.keyExists( arguments.id );
}

public array function getPagesByCategory( required string category ) {
var matchedPages = [];

Expand Down
25 changes: 20 additions & 5 deletions builders/html/Builder.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,35 @@ component {
);
var crumbs = [];
var parent = arguments.page.getParent();
var links = [];


while( !IsNull( parent ) ) {
crumbs.prepend( parent.getId() );
parent = parent.getParent();
}

if ( !IsNull( arguments.page.getCategories() ) ) {
for( var category in arguments.page.getCategories() ) {
if ( arguments.docTree.pageExists( "category-" & category ) ) {
links.append( "[[category-" & category & "]]" );
}
}
}
if ( !IsNull( arguments.page.getRelated() ) ) {
for( var link in arguments.page.getRelated() ) {
links.append( link );
}
}

return renderTemplate(
template = "layouts/main.cfm"
, args = {
body = Trim( renderedPage )
, page = arguments.page
, crumbs = renderTemplate( template="layouts/breadcrumbs.cfm", args={ crumbs=crumbs, page=arguments.page } )
, navTree = renderTemplate( template="layouts/sideNavTree.cfm", args={ crumbs=crumbs, docTree=arguments.docTree, pageLineage=arguments.page.getLineage() } )
, seeAlso = renderTemplate( template="layouts/seeAlso.cfm", args={ links=arguments.page.getRelated() } )
body = Trim( renderedPage )
, page = arguments.page
, crumbs = renderTemplate( template="layouts/breadcrumbs.cfm", args={ crumbs=crumbs, page=arguments.page } )
, navTree = renderTemplate( template="layouts/sideNavTree.cfm", args={ crumbs=crumbs, docTree=arguments.docTree, pageLineage=arguments.page.getLineage() } )
, seeAlso = renderTemplate( template="layouts/seeAlso.cfm" , args={ links=links } )
}
);
}
Expand Down
10 changes: 5 additions & 5 deletions builders/html/layouts/main.cfm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<cfparam name="args.body" type="string" />
<cfparam name="args.page" type="any" />
<cfparam name="args.crumbs" type="string" />
<cfparam name="args.navTree" type="string" />
<cfparam name="args.seeAlso" type="string" />
<cfparam name="args.body" type="string" />
<cfparam name="args.page" type="any" />
<cfparam name="args.crumbs" type="string" />
<cfparam name="args.navTree" type="string" />
<cfparam name="args.seeAlso" type="string" />

<cfoutput><!DOCTYPE html>
<html>
Expand Down

0 comments on commit 493f8d9

Please sign in to comment.