内容详情页show.html调用收藏按钮
<a href="javascript:dr_app_favorite('{$id}');" class="icon-btn"><span class="badge badge-danger" id="module_favorite_{$id}"> {intval($favorites)} </span></a> <script> // 模块收藏 function dr_app_favorite(id) { $.get("{dr_url_prefix('index.php')}?is_ajax=1&s=api&app={MOD_DIR}&c=module&m=favorite&id="+id, function(data){ dr_cmf_tips(data.code, data.msg); if (data.code) { $('#module_favorite_'+id).html(data.data); } }, 'json'); } </script>
内容详情页show.html判断当前登录用户是否收藏了
{if \Phpcmf\Service::M()->db->table(SITE_ID.'_'.MOD_DIR.'_favorite')->where('cid', $id)->where('uid', $member.uid)->countAllResults()} 收藏了 {else} 没有 {/if}