Skip to content

Commit

Permalink
When we have multiple laws, deep link to the laws after the first. #686
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Hunt committed Apr 8, 2017
1 parent 09ef7a4 commit e389ee6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion htdocs/law.php
Expand Up @@ -232,7 +232,7 @@
/*
* Start assembling the body of this page by indicating the beginning of the text of the section.
*/
$body .= '<article class="law-contents">';
$body .= '<article class="law-contents" id="law-' . $law->law_id . '">';

$body .= '<h1>
<span class="section_id">' . SECTION_SYMBOL .'&nbsp;' . $law->section_number . '</span>
Expand Down
7 changes: 6 additions & 1 deletion htdocs/structure.php
Expand Up @@ -338,8 +338,13 @@

foreach ($laws as $law)
{
$url = $law->url;
if($law->metadata && isset($law->metadata->dupe_number)) {
$url .= '#law-' . $law->id;
}

$body .= '<tr>
<td><a href="' . $law->url . '">'
<td><a href="' . $url . '">'
. SECTION_SYMBOL . '&nbsp;' . $law->section_number . '</a></td>
<td><a href="' . $law->url . '">'
. $law->catch_line . '</a></td></tr>';
Expand Down
15 changes: 11 additions & 4 deletions includes/class.Structure.inc.php
Expand Up @@ -650,9 +650,14 @@ function list_laws()
}

/*
* Create a new, empty class.
* Create a new, empty array.
*/
$laws = new stdClass();
$laws = array();

/*
* Instantiate our laws class.
*/
$law = new Law(array('db' => $this->db));

/*
* Return the result as an object, built up as we loop through the results.
Expand All @@ -669,8 +674,10 @@ function list_laws()
$section->catch_line = '[Untitled]';
}

$laws->$i = $section;
$i++;
$law->section_id = $section->id;
$section->metadata = $law->get_metadata();

$laws[] = $section;

}

Expand Down

0 comments on commit e389ee6

Please sign in to comment.