Skip to content

Commit

Permalink
#18 - Tweak bookmarking functionality to allow for templating
Browse files Browse the repository at this point in the history
  • Loading branch information
Moc committed Dec 19, 2022
1 parent 717dd6a commit c321da5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cookbook_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function bookmarkRecipe()
{
$ret['status'] = "ok";
$ret['action'] = "removed";
$ret['msg'] = "<i class='fa-li far fa-bookmark'></i> <a href='#'>".LAN_CB_ADDTOBOOKMARKS."</a>";
$ret['msg'] = LAN_CB_ADDTOBOOKMARKS;
}
}
// Not yet bookmarked, so insert into database
Expand All @@ -99,7 +99,7 @@ public function bookmarkRecipe()
{
$ret['status'] = "ok";
$ret['action'] = "added";
$ret['msg'] = "<i class='fa-li fas fa-bookmark'></i> <a href='#'>".LAN_CB_REMOVEFROMBOOKMARKS."</a>";
$ret['msg'] = LAN_CB_REMOVEFROMBOOKMARKS;
}

}
Expand Down
16 changes: 12 additions & 4 deletions cookbook_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ function sc_cookbook_recipe_edit($parm = array())
}


function sc_cookbook_bookmark($parm = '')
function sc_cookbook_recipe_bookmark($parm = '')
{
$bookmark_pref = e107::getPlugPref('cookbook', 'recipe_showbookmark', 1);

Expand All @@ -677,16 +677,24 @@ function sc_cookbook_bookmark($parm = '')
// Not bookmarked yet, display 'empty' bookmark icon
if(!$bookmarked)
{
$text = '<i class="fa-li far fa-bookmark"></i> '.LAN_CB_ADDTOBOOKMARKS;
$value = LAN_CB_ADDTOBOOKMARKS;
$template = e107::getTemplate('cookbook', 'cookbook', 'recipe_bookmark_empty');

}
// Already bookmarked, display 'full' bookmark icon
else
{
$text = '<i class="fa-li fas fa-bookmark"></i> '.LAN_CB_REMOVEFROMBOOKMARKS;
$value = LAN_CB_REMOVEFROMBOOKMARKS;
$template = e107::getTemplate('cookbook', 'cookbook', 'recipe_bookmark_full');
}

return '<li><span data-cookbook-action="bookmark" data-cookbook-recipeid="'.$this->var['r_id'].'"><a href="">'.$text.'</a></span></li>';
$vars = array(
'VALUE' => $value,
);

$text = e107::getParser()->simpleParse($template, $vars);

return '<span data-cookbook-action="bookmark" data-cookbook-recipeid="'.$this->var['r_id'].'">'.$text.'</span>';
}


Expand Down
1 change: 1 addition & 0 deletions js/cookbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
var newText = response.msg;
$('span[data-cookbook-recipeid='+recipeID+']').html(newText);
//console.log("going to reload")
//alert("going to reload")
//location.reload();
}
else
Expand Down
6 changes: 5 additions & 1 deletion templates/cookbook_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<h3>{LAN=LAN_CB_ACTIONS}</h3>
<ul class="fa-ul">
{COOKBOOK_BOOKMARK}
<li>{COOKBOOK_RECIPE_BOOKMARK}</li>
<li>{GLYPH: type=fa-pencil&class=fa-li} {COOKBOOK_RECIPE_EDIT}</li>
<li>{GLYPH: type=fa-print&class=fa-li} {COOKBOOK_RECIPE_PRINT}</li>
</ul>
Expand All @@ -153,6 +153,10 @@
// Styling of an individual keyword (when using {COOKBOOK_RECIPE_KEYWORDS})
$COOKBOOK_TEMPLATE['recipe_keyword'] = '<a href="{URL}" title="{KEYWORD}"><span class="label label-primary">{KEYWORD}</span></a>';

// Styling of bookmark
$COOKBOOK_TEMPLATE['recipe_bookmark_empty'] = '<i class="fa-li far fa-bookmark"></i> <a href="">{VALUE}</a>'; // Used when recipe has not been bookmarked yet
$COOKBOOK_TEMPLATE['recipe_bookmark_full'] = '<i class="fa-li fas fa-bookmark"></i> <a href="">{VALUE}</a>'; // Used when recipe is already bookmarked

// KEYWORD OVERVIEW (TAGCLOUD) (div #id should always be 'recipe_tagcloud')
$COOKBOOK_TEMPLATE['keyword_overview'] = '
{COOKBOOK_TAGCLOUD}
Expand Down

0 comments on commit c321da5

Please sign in to comment.