Skip to content

Commit

Permalink
[themes] make a build_tag function which themes can override, see #1328
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Dec 13, 2024
1 parent adac4f4 commit d629a5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions core/themelet.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ private function get_common(): Themelet
return self::$common;
}

public function build_tag(string $tag): HTMLElement
{
$c = self::get_common();
assert(is_a($c, CommonElementsTheme::class));
return $c->build_tag($tag);
}

public function build_thumb(Image $image): HTMLElement
{
$c = self::get_common();
Expand Down
9 changes: 9 additions & 0 deletions ext/common_elements/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

class CommonElementsTheme extends Themelet
{
public function build_tag(string $tag): HTMLElement
{
return A([
"href" => search_link([$tag]),
"class" => "tag",
"title" => "View all posts tagged $tag"
], $tag);
}

/**
* Generic thumbnail code; returns HTML rather than adding
* a block since thumbs tend to go inside blocks...
Expand Down
6 changes: 1 addition & 5 deletions ext/post_tags/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public function get_tag_editor_html(Image $image): HTMLElement

$tag_links = [];
foreach ($image->get_tag_array() as $tag) {
$tag_links[] = A([
"href" => search_link([$tag]),
"class" => "tag",
"title" => "View all posts tagged $tag"
], $tag);
$tag_links[] = $this->build_tag($tag);
}

return SHM_POST_INFO(
Expand Down

0 comments on commit d629a5e

Please sign in to comment.