Peter F. Posted July 9, 2009 Share Posted July 9, 2009 I've been trying a number of different methods to create a hook that uses post specific data to no avail. Mainly due to the fact that the topicViewTemplate contains the foreach loop within the template combined with the inability of template hooks to access any data that is used within the template itself. If there is a way to do this that I'm missing I apologise. The only way currently that I can see to get post specific data is to completely duplicate the topicViewTemplate in a skinOverloader, but that would cause problems if multiple modders wanted to use hooks in different sections of the topicViewTemplate, one skinOverloader would overwrite another. Would it be possible for the topicViewTemplate to be split into two separate templates, one for the topic as a whole and another for a post which would be called by the topic template each time it wanted to run a post. That way at least a skinOverloader could be called that could pass post specific data to a template hook to be used. Link to comment Share on other sites More sharing options...
Martin A. Posted July 9, 2009 Share Posted July 9, 2009 Or perhaps just do something with foreach template hooks. For each iteration, do something that triggers the hook, and pass the same data used in foreach() to getOutput(), or something. Link to comment Share on other sites More sharing options...
Peter F. Posted July 9, 2009 Author Share Posted July 9, 2009 With the foreach template hooks though you still run into the problem that you can't access any of the data that is actually used in the post itself. For example using the "foreach hook" I am not able to access the $post variable that is used in the topicViewTemplate which contains the post specific data I'm looking to use. Nor would using the "foreach hook" allow me to place the data where I want it to go in each post unless hooks are given access to the post that has been generated by the template, in which case regex could be used to perform replacements or insertions to each post on the fly using the foreach hook. But from my examinations of the IPB code this is not what happens. From what I can see this is what happens: Additionally there is no way, that I can see, at present to make an "if hook" run separately for each post, even if the "foreach hook" is used, and thus no way for IPB to differentiate between the hook being placed in post #1 and the hook being placed in post #2. IPB parses the topicViewTemplate for the topic. IPB then checks to see if there are any hook points that will fit in. If there are IPB parses those hook points separately and places them into the hook point. IPB then removes any hooks points that have not been used and displays the topic Link to comment Share on other sites More sharing options...
Peter F. Posted July 9, 2009 Author Share Posted July 9, 2009 For the record my suggestion would be to do something like change this template: // Name: topicViewTemplate //=========================================================================== function topicViewTemplate($forum, $topic, $post_data, $displayData) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <if test="allowRating:|:$forum['forum_allow_rating']"> {parse js_module="rating"} </if> {parse js_module="topic"} {parse js_module="editor"} <script type="text/javascript"> //<![CDATA[ ipb.topic.inSection = 'topicview'; ipb.topic.topic_id = {$topic['tid']}; ipb.topic.forum_id = {$forum['id']}; ipb.topic.start_id = {parse expression="intval($this->request['st'])"}; // Editor JS: Only needs to be done once per page {parse template="editorJS" group="editors" params=""} //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = {$forum['id']}; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = {$topic['tid']}; //]]> </script> {parse template="include_lightbox" group="global" params=""} <if test="showForumRulesInline:|:$forum['show_rules'] == 2"> <div class='message unspecific'> <h3>{$forum['rules_title']}</h3> {$forum['rules_text']} </div> </if> <if test="showForumRulesLink:|:$forum['show_rules'] == 1"> <div class='message unspecific'> <a href='{parse url="app=forums&module=forums&section=rules&f={$forum['id']}" base="public"}' title='{$this->lang->words['show_forum_rules']}'><strong>{$forum['rules_title']}</strong></a> </div> </if> <if test="isNotThreadedMode:|:$displayData['threaded_mode_enabled'] == 0"> <div class='topic_controls'> {$topic['SHOW_PAGES']} <ul class='topic_buttons'> <if test="newTopicButton:|:$forum['_user_can_post']"> <li><a href='{parse url="module=post&section=post&do=new_post&f={$forum['id']}" base="publicWithApp"}' title='{$this->lang->words['start_new_topic']}' accesskey='n'>{parse replacement="topic_icon"} {$this->lang->words['start_new_topic']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_start']}</span></li> </if> <if test="closedButton:|:$topic['state'] == 'closed'"> <li class='closed'> <if test="closedButtonLink:|:$displayData['reply_button']['url']"> <a href='{$displayData['reply_button']['url']}' accesskey='r'>{parse replacement="lock_icon"} {$this->lang->words['top_locked_reply']}</a> <else /> <span>{parse replacement="lock_icon"} {$this->lang->words['top_locked']}</span> </if> </li> <else /> <if test="replyButton:|:$displayData['reply_button']['image']"> <if test="replyButtonLink:|:$displayData['reply_button']['url']"> <li><a href='{$displayData['reply_button']['url']}' title='{$this->lang->words['topic_add_reply']}' accesskey='r'>{parse replacement="reply_icon"} {$this->lang->words['topic_add_reply']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_reply']}</span></li> </if> </if> </if> <if test="watchWrapper:|:$this->memberData['member_id']"> <li> <if test="isWatching:|:$this->settings['cpu_watch_update'] AND $topic['trackingTopic']"> <a href='{parse url="app=core&module=usercp&tab=forums&area=updateWatchTopics&do=saveIt&authKey={$this->member->form_hash}&topicIDs[{$topic['tid']}]=1&trackchoice=unsubscribe&topicReturn={$topic['tid']}" base="public"}' title='{$this->lang->words['topic_stop_watching']}'>{parse replacement="watch_topic_off"} {$this->lang->words['topic_stop_watching']}</a> <else /> <a href='{parse url="app=core&module=usercp&tab=forums&area=watch&watch=topic&do=list&tid={$topic['tid']}" base="public"}' title='{$this->lang->words['tt_title']}'>{parse replacement="watch_topic_on"} {$this->lang->words['tt_title']}</a> </if> </li> </if> </ul> </div> <script type='text/javascript'> //<![CDATA[ if( $('watch_opts_menucontent') ){ $('watch_opts_menucontent').hide(); } //]]> </script> </if> <div class='topic hfeed'> <h2 class='maintitle'> <span class='main_topic_title'> {$topic['title']} <if test="topicDescription:|:$topic['description']"> <span class='desc main_topic_desc'>{$topic['description']}</span> </if> </span> <!-- SKINNOTE: Need to fill in proper URL for topic rating --> <if test="topicRating:|:$forum['forum_allow_rating']"> <span class='rating'>{$this->lang->words['js_rate_me']} <a href='{parse url="app=forums&module=extras&section=rating&t={$topic['tid']}&rating=1" base="public"}' id='topic_rate_1' title='{$this->lang->words['top_js_1star']}'><if test="rate1:|:$topic['_rate_int'] >= 1">{parse replacement="rate_on"}<else />{parse replacement="rate_off"}</if></a><a href='{parse url="app=forums&module=extras&section=rating&t={$topic['tid']}&rating=2" base="public"}' id='topic_rate_2' title='{$this->lang->words['top_js_2star']}'><if test="rate2:|:$topic['_rate_int'] >= 2">{parse replacement="rate_on"}<else />{parse replacement="rate_off"}</if></a><a href='{parse url="app=forums&module=extras&section=rating&t={$topic['tid']}&rating=3" base="public"}' id='topic_rate_3' title='{$this->lang->words['top_js_3star']}'><if test="rate3:|:$topic['_rate_int'] >= 3">{parse replacement="rate_on"}<else />{parse replacement="rate_off"}</if></a><a href='{parse url="app=forums&module=extras&section=rating&t={$topic['tid']}&rating=4" base="public"}' id='topic_rate_4' title='{$this->lang->words['top_js_4star']}'><if test="rate4:|:$topic['_rate_int'] >= 4">{parse replacement="rate_on"}<else />{parse replacement="rate_off"}</if></a><a href='{parse url="app=forums&module=extras&section=rating&t={$topic['tid']}&rating=5" base="public"}' id='topic_rate_5' title='{$this->lang->words['top_js_5star']}'><if test="rate5:|:$topic['_rate_int'] >= 5">{parse replacement="rate_on"}<else />{parse replacement="rate_off"}</if></a> <span id='rating_text'> <if test="hasRates:|:$topic['topic_rating_hits'] > 0"><span id='rating_hits'>{$topic['topic_rating_hits']}</span> {$this->lang->words['poll_s_votes']}</if> <if test="youRated:|:$topic['_rating_value'] != -1"> ({$this->lang->words['topic_poll_your_vote']} <span id='your_rate'>{$topic['_rating_value']}</span>)</if> </span> <script type='text/javascript'> //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: '{parse url="app=forums&module=ajax§ion=topics&do=rateTopic&t={$topic['tid']}" base="public"}&md5check=' + ipb.vars['secure_hash'], cur_rating: {$topic['_rate_int']}, rated: <if test="jsHasRates:|:$topic['_rating_value'] != -1">1<else />0</if>, allow_rate: {$topic['_allow_rate']}, multi_rate: 1, show_rate_text: true } ); //]]> </script> </span> </if> </h2> {$displayData['poll_data']} <if test="startModForm:|:$displayData['mod_links']"> <if test="weAreMod:|:$this->memberData['is_mod'] OR $this->memberData['member_id'] == $topic['starter_id']"> <form id="modform" method="post" action="{parse url="" base="public"}"> <fieldset> <input type="hidden" name="app" value="forums" /> <input type="hidden" name="module" value="moderate" /> <input type="hidden" name="section" value="moderate" /> <input type="hidden" name="do" value="postchoice" /> <input type="hidden" name="f" value="{$topic['forum_id']}" /> <input type="hidden" name="t" value="{$topic['tid']}" /> <input type="hidden" name="auth_key" value="{$this->member->form_hash}" /> <input type="hidden" name="st" value="{$this->request['st']}" /> <input type="hidden" value="{$this->request['selectedpids']}" name="selectedpidsJS" id='selectedpidsJS' /> </fieldset> </if> </if> <if test="hasPosts:|:is_array( $post_data ) AND count( $post_data )"> <!-- skinnote: Posts by ignored users are not hidden, check _ignored --> <foreach loop="post_data:$post_data as $pid => $post"> <!--Begin Msg Number {$post['post']['pid']}--> <div class='post_block hentry clear <if test="repHighlight:|:$this->settings['reputation_highlight'] AND $post['post']['rep_points'] >= $this->settings['reputation_highlight']">rep_highlight</if> <if test="postQueued:|:$post['post']['queued']==1">moderated</if> <if test="reputation:|:$this->settings['reputation_enabled']">with_rep</if>' id='post_id_{$post['post']['pid']}'> <a id='entry{$post['post']['pid']}'></a> <if test="repIgnored:|:( isset( $post['post']['_repignored'] ) AND isset($post['post']['_ignored']) ) AND $post['post']['_repignored'] == 1 && $post['post']['_ignored'] != 1"> <div class='post_ignore'> <if test="noRep:|:$post['post']['rep_points'] == 0"> <span class='reputation zero' title='{$this->lang->words['top_rep']}'> </if> <if test="posRep:|:$post['post']['rep_points'] > 0"> <span class='reputation positive' title='{$this->lang->words['top_rep']}'> </if> <if test="negRep:|:$post['post']['rep_points'] < 0"> <span class='reputation negative' title='{$this->lang->words['top_rep']}' > </if> {$post['post']['rep_points']}</span> {$this->lang->words['top_this_post_by']} <a href='{parse url="showuser={$post['author']['member_id']}" base="public"}'>{$post['author']['members_display_name']}</a> {parse template="user_popup" group="global" params="$post['author']['member_id'], $post['author']['members_seo_name']"} {$this->lang->words['top_below_thresh']}. <a href='#' title='{$this->lang->words['ignore_view_post']}' id='unhide_post_{$post['post']['pid']}'>{$this->lang->words['rep_view_anyway']}</a> </div> </if> <if test="userIgnored:|:$post['post']['_ignored'] == 1"> <div class='post_ignore'> {$this->lang->words['post_ignored']} <a href='{parse url="showuser={$post['author']['member_id']}" base="public"}'>{$post['author']['members_display_name']}</a> {parse template="user_popup" group="global" params="$post['author']['member_id'], $post['author']['members_seo_name']"}. <a href='#entry{$post['post']['pid']}' title='{$this->lang->words['ignore_view_post']}' style='display: none' id='unhide_post_{$post['post']['pid']}'>{$this->lang->words['rep_view_anyway']}</a> </div> </if> <div class='post_wrap' <if test="isNotIgnoring:|:$post['post']['_ignored'] == 1 || $post['post']['_repignored'] == 1">style='display: none'</if>> <if test="postMid:|:$post['author']['member_id']"> <h3> <else /> <h3 class='guest'> </if> <span class='post_id'><a href='{parse url="showtopic={$post['post']['topic_id']}&view=findpost&p={$post['post']['pid']}" template="showtopic" seotitle="{$topic['title_seo']}" base="public"}' rel='bookmark' title='{$this->lang->words['link_to_post']} #{$post['post']['post_count']}'>#{$post['post']['post_count']}</a></span> <if test="postMember:|:$post['author']['member_id']"> <if test="postOnline:|:$post['author']['_online']"> {parse replacement="user_online"} <else /> {parse replacement="user_offline"} </if> <span class="author vcard"><a class="url fn" href='{parse url="showuser={$post['author']['member_id']}" base="public" template="showuser" seotitle="{$post['author']['members_seo_name']}"}'>{$post['author']['members_display_name']}</a>{parse template="user_popup" group="global" params="$post['author']['member_id'], $post['author']['members_seo_name']"}</span> <else /> {$post['author']['members_display_name']} </if> <if test="postIp:|:$post['post']['_show_ip']"> <span class='ip'>({$this->lang->words['ip']}: <if test="postAdmin:|:$post['author']['g_access_cp']"> <em>{$this->lang->words['ip_private']}</em> <else /> <a href="{parse url="app=core&module=usercp&tab=members&area=mod_ipaddress&do=custom&ip={$post['post']['ip_address']}" base="public"}" title='{$this->lang->words['info_about_this_ip']}'>{$post['post']['ip_address']}</a> </if> )</span> </if> </h3> <div class='author_info'> {parse template="userInfoPane" group="global" params="$post['author'], $post['post']['pid'], array()"} </div> <div class='post_body'> <p class='posted_info'> <if test="postModCheckbox:|:$this->memberData['is_mod']"> <if test="postModSelected:|:isset( $post['post']['_pid_selected'] ) && $post['post']['_pid_selected']"> <label for='checkbox_{$post['post']['pid']}' class='post_mod hide'>{$this->lang->words['mod_select_post']}</label><input type='checkbox' id='checkbox_{$post['post']['pid']}' name='selectedpids[]' value='{$post['post']['pid']}' class='post_mod' checked='checked' /> <else /> <label for='checkbox_{$post['post']['pid']}' class='post_mod hide'>{$this->lang->words['mod_select_post']}</label><input type='checkbox' id='checkbox_{$post['post']['pid']}' name='selectedpids[]' value='{$post['post']['pid']}' class='post_mod' /> </if> </if> <if test="postIcon:|:$post['post']['icon_id']"> <img src="{$this->settings['public_dir']}/style_extra/post_icons/icon{$post['post']['icon_id']}.gif" alt="{$this->lang->words['post_icon']}" /> </if> {$this->lang->words['posted']} <abbr class="published" title="{parse expression="date( 'c', $post['post']['post_date'] )"}">{parse date="$post['post']['post_date']" format="long"}</abbr> </p> <div class='post entry-content'> {$post['post']['post']} {$post['post']['attachmentHtml']} <br /> <if test="postEditBy:|:$post['post']['edit_by']"> <p class='edit'> {$post['post']['edit_by']} <if test="postEditByReason:|:$post['post']['post_edit_reason'] != ''"> <br /> <span class='reason'>{$this->lang->words['reason_for_edit']}: {$post['post']['post_edit_reason']}</span> </if> </p> </if> </div> <if test='postSignature:|:$post['post']['signature']'> {$post['post']['signature']} </if> </div> <if test="reputationBox:|:$this->settings['reputation_enabled']"> <if test="canRep:|:!( $this->settings['reputation_protected_groups'] && in_array( $post['author']['member_group_id'], explode( ',', $this->settings['reputation_protected_groups'] ) ) )"> <div class='rep_bar clear right' id='rep_post_{$post['post']['pid']}'> <if test="repHighlight:|:$this->settings['reputation_highlight'] AND $post['post']['rep_points'] >= $this->settings['reputation_highlight']"> <span class='rep_highlight'>{$this->lang->words['popular_post']}</span> </if> <if test="hasNoRep:|:$post['post']['rep_points'] == 0"> <span class='reputation zero rep_show' title='{$this->lang->words['reputation']}'> </if> <if test="hasPosRep:|:$post['post']['rep_points'] > 0"> <span class='reputation positive rep_show' title='{$this->lang->words['reputation']}'> </if> <if test="hasNegRep:|:$post['post']['rep_points'] < 0"> <span class='reputation negative rep_show' title='{$this->lang->words['reputation']}' > </if> {$post['post']['rep_points']} </span> <if test="hasNotGivenRep:|:$post['post']['has_given_rep'] != 1 AND $post['post']['has_given_rep'] != -1 AND $this->memberData['member_id'] != 0 && ( $this->settings['reputation_can_self_vote'] OR $post['author']['member_id'] != $this->memberData['member_id'] )"> <ul> <if test="giveRepUp:|:$this->settings['reputation_point_types'] == 'positive' || $this->settings['reputation_point_types'] == 'both'"> <li><a href='{$this->settings['base_url']}app=core&module=global&section=reputation&do=add_rating&app_rate=forums&type=pid&type_id={$post['post']['pid']}&rating=1&secure_key={$this->member->form_hash}&post_return={$post['post']['pid']}' class='rep_up' title='{$this->lang->words['reputation_up']}'>{parse replacement="rep_up"}</a></li> </if> <if test="giveRepDown:|:$this->settings['reputation_point_types'] == 'negative' || $this->settings['reputation_point_types'] == 'both'"> <li><a href='{$this->settings['base_url']}app=core&module=global&section=reputation&do=add_rating&app_rate=forums&type=pid&type_id={$post['post']['pid']}&rating=-1&secure_key={$this->member->form_hash}&post_return={$post['post']['pid']}' class='rep_down' title='{$this->lang->words['reputation_down']}'>{parse replacement="rep_down"}</a></li> </if> </ul> </if> </div> </if> <script type='text/javascript'> ipb.global.registerReputation( 'rep_post_{$post['post']['pid']}', { app: 'forums', type: 'pid', typeid: '{$post['post']['pid']}' }, parseInt('{$post['post']['rep_points']}') ); </script> </if> <ul class='post_controls'> <if test="canReportPost:|:($this->settings['disable_reportpost'] != 1) and ( $this->memberData['member_id'] )"> <li class='report'> <a href='{parse url="app=core&module=reports&rcom=post&tid={$this->request['t']}&pid={$post['post']['pid']}&st={$this->request['st']}" base="public"}'>{parse replacement="report_post_icon"} {$this->lang->words['report']}</a> </li> <if test="postIsReported:|:$this->memberData['_cache']['report_temp']['post_marker']['post'][ $post['post']['pid'] ]['gfx'] > 0"> <li class='report'> <a href="{$this->settings['base_url']}app=core&module=reports&section=reports&do=show_report&rid={$this->memberData['_cache']['report_temp']['post_marker']['post'][$post['post']['pid']]['info']['id']}" id='post-report-{$post['post']['pid']}' class='ipbmenu'> <span id="rstat-{$this->memberData['_cache']['report_temp']['post_marker']['post'][ $post['post']['pid'] ]['info']['id']}"><img src="{$this->settings['img_url']}/reports/post_alert_{$this->memberData['_cache']['report_temp']['post_marker']['post'][$post['post']['pid']]['gfx']}.png" alt="{$this->lang->words['icon']}" /></span> </a> </li> </if> </if> <li class='top hide'><a href='#top' class='top' title='{$this->lang->words['back_top']}'>{$this->lang->words['back_top']}</a></li> <if test="multiquote:|:isset( $post['post']['_mq_selected'] ) && $post['post']['_mq_selected']"> <li class='selected multiquote' id='multiq_{$post['post']['pid']}' style='display: none'> <else /> <li class='multiquote' id='multiq_{$post['post']['pid']}' style='display: none'> </if> <a href="{parse url="module=post&section=post&do=reply_post&f={$this->request['f']}&t={$this->request['t']}&qpid={$post['post']['pid']}" base="publicWithApp"}" title="{$this->lang->words['quote_with_mq']}">{parse replacement="mq_post_icon"} {$this->lang->words['mq']}</a> </li> <li><a href="{parse url="module=post&section=post&do=reply_post&f={$this->request['f']}&t={$this->request['t']}&qpid={$post['post']['pid']}" base="publicWithApp"}" title="{$this->lang->words['tt_reply_to_post']}">{parse replacement="reply_post_icon"} {$this->lang->words['post_reply']}</a></li> <if test="canEdit:|:$post['post']['_can_edit'] === TRUE"> <li class='post_edit'><a href='{parse url="module=post&section=post&do=edit_post&f={$forum['id']}&t={$topic['tid']}&p={$post['post']['pid']}&st={$this->request['st']}" base="publicWithApp"}' title='{$this->lang->words['post_edit_title']}' class='edit_post' id='edit_post_{$post['post']['pid']}'>{parse replacement="edit_post_icon"} {$this->lang->words['post_edit']}</a></li> </if> <if test="canDelete:|:$post['post']['_can_delete'] === TRUE"> <li class='post_del' id='del_post_{$post['post']['pid']}'> <a href='{parse url="module=moderate&section=moderate&do=04&f={$forum['id']}&t={$topic['tid']}&p={$post['post']['pid']}&st={$this->request['st']}&auth_key={$this->member->form_hash}" base="publicWithApp"}' title='{$this->lang->words['post_delete_title']}' class='delete_post'>{parse replacement="delete_post_icon"} {$this->lang->words['post_delete']}</a> </li> </if> <!-- Matt: Approve / unapprove post button --> <if test="approvePost:|:$this->memberData['is_mod']"> <li class='post_toggle toggle_post' id='toggle_post_{$post['post']['pid']}' style='display: none'> <a href='{parse url="app=forums&module=forums&section=moderate&do=postchoice&tact=unapprove&selectedpids[{$post['post']['pid']}]=1" base="public"}' title='{$this->lang->words['post_toggle_visible']}'>{parse replacement="edit_post_icon"} <span id='toggletext_post_{$post['post']['pid']}'><if test="approveUnapprove:|:$post['post']['queued']==1">{$this->lang->words['post_approve']}<else />{$this->lang->words['post_unapprove']}</if></span></a> </li> </if> </ul> <script type='text/javascript'> // Show multiquote for JS browsers $('multiq_{$post['post']['pid']}').show(); if( $('toggle_post_{$post['post']['pid']}') ) { $('toggle_post_{$post['post']['pid']}').show(); } </script> <if test="reportedPostData:|:$this->memberData['_cache']['report_temp']['post_marker']['post'][ $post['post']['pid'] ]['gfx'] > 0"> <ul id='post-report-{$post['post']['pid']}_menucontent' class='ipbmenu_content'> <li><a href="{parse url="app=core&module=reports&do=show_report&rid={$this->memberData['_cache']['report_temp']['post_marker']['post'][ $post['post']['pid'] ]['info']['id']}" base="public"}" id='report_mark_{$post['post']['pid']}'><img src='{$this->settings['img_url']}/reports/mark_complete.png' alt='' /> {$this->lang->words['report_menu_mark_complete']}</a></li> <li><a href="{$this->settings['base_url']}app=core&module=reports&section=reports&do=show_report&rid={$this->memberData['_cache']['report_temp']['post_marker']['post'][$post['post']['pid']]['info']['id']}"><img src='{$this->settings['img_url']}/reports/view_report.png' alt='' /> {$this->lang->words['report_menu_view_report']}</a></li> </ul> <script type="text/javascript"> $('report_mark_{$post['post']['pid']}').observe('click', ipb.global.updateReportStatus.bindAsEventListener( this, {$this->memberData['_cache']['report_temp']['post_marker']['post'][$post['post']['pid']]['info']['id']},2,2 ) ); </script> </if> </div> <!-- </if> --> </div> <if test="initIgnoredPost:|:$post['post']['_repignored'] == 1 || $post['post']['_ignored']"> <script type='text/javascript'> ipb.topic.setPostHidden( {$post['post']['pid']} ); $('unhide_post_{$post['post']['pid']}').show(); </script> </if> <hr /> <if test="endFirstPost:|:$post['post']['_end_first_post']"> <!-- END OF FIRST POST IN LINEAR+, SHOW BUTTONS AND NEW TITLE --> <br /> <div class='topic_controls'> {$topic['SHOW_PAGES']} <ul class='topic_buttons'> <if test="bottomNewTopic:|:$forum['_user_can_post']"> <li><a href='{parse url="module=post&section=post&do=new_post&f={$forum['id']}" base="publicWithApp"}' title='{$this->lang->words['start_new_topic']}' accesskey='n'>{parse replacement="topic_icon"} {$this->lang->words['start_new_topic']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_start']}</span></li> </if> <if test="bottomIsClosed:|:$topic['state'] == 'closed'"> <li class='closed'> <if test="bottomClosedButtonLink:|:$displayData['reply_button']['url']"> <a href='{$displayData['reply_button']['url']}' accesskey='r'>{parse replacement="lock_icon"} {$this->lang->words['top_locked_reply']}</a> <else /> <span>{parse replacement="lock_icon"} {$this->lang->words['top_locked']}</span> </if> </li> <else /> <if test="bottomReplyButton:|:$displayData['reply_button']['image']"> <if test="bottomReplyButtonLink:|:$displayData['reply_button']['url']"> <li><a href='{$displayData['reply_button']['url']}' title='{$this->lang->words['topic_add_reply']}' accesskey='r'>{parse replacement="reply_icon"} {$this->lang->words['topic_add_reply']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_reply']}</span></li> </if> </if> </if> </ul> </div> <h2 class='maintitle'>{$this->lang->words['topic_other_replies']}</h2> <div class='generic_bar'></div> </if> </foreach> </if> <!-- MOD LINKS --> <if test="modOptions:|:$displayData['mod_links']"> <if test="showModOptions:|:$this->memberData['is_mod'] OR $this->memberData['member_id'] == $topic['starter_id']"> <div id='topic_mod' class='moderation_bar rounded with_action clear'> <if test="showModOptionsinner:|:$this->memberData['is_mod']"> <label for='tact' class='hide'>{$this->lang->words['post_moderation']}</label> <select name="tact" id='tact' class='input_select'> <option value="">{$this->lang->words['post_moderation']}</option> <option value="merge">{$this->lang->words['cpt_merge']}</option> <option value="move">{$this->lang->words['cpt_move']}</option> <option value="delete">{$this->lang->words['cpt_delete']}</option> <option value="split">{$this->lang->words['cpt_split']}</option> <option value="approve">{$this->lang->words['cpt_approve']}</option> <option value="unapprove">{$this->lang->words['cpt_unapprove']}</option> </select> <input type="submit" id='mod_submit' name="gobutton" value="{$this->lang->words['f_go']}<if test="modButtonCount:|:$this->request['selectedpidcount']"> ({$this->request['selectedpidcount']})</if>" class="input_submit alt" /> </if> </div> </form> <script type='text/javascript'> $('modform').observe('submit', ipb.topic.submitPostModeration ); </script> <div id='topic_mod_2' class='moderation_bar rounded'> <if test="mmModOptions:|:is_array( $displayData['multi_mod'] ) AND count( $displayData['multi_mod'] )"> <form action="{parse url="app=forums&module=moderate&section=multimod&t={$topic['tid']}" base="public"}" method="post" id='multimod' class='left'> <fieldset> <input type="hidden" name="check" value="1" /> <select name="mm_id" class="input_select"> <option value="-1">{$this->lang->words['mm_title']}</option> <foreach loop="mm:$displayData['multi_mod'] as $mm_data"> <option value="{$mm_data[0]}">{$mm_data[1]}</option> </foreach> </select> <input type="submit" value="{$this->lang->words['mm_submit']}" class="input_submit alt" /> </fieldset> </form> </if> <form method="post" id="modform2" action="{parse url="" base="public"}"> <fieldset> <input type="hidden" name="t" value="{$topic['tid']}" /> <input type="hidden" name="f" value="{$topic['forum_id']}" /> <input type="hidden" name="st" value="{$this->request['st']}" /> <input type="hidden" name="auth_key" value="{$this->member->form_hash}" /> <input type="hidden" name="app" value="forums" /> <input type="hidden" name="module" value="moderate" /> <input type="hidden" name="section" value="moderate" /> <label for='topic_moderation' class='hide'>{$this->lang->words['topic_moderation']}</label> <select name="do" class="input_select" id='topic_moderation'> <option value="-1">{$this->lang->words['topic_moderation']}</option> <foreach loop="mod_links:$displayData['mod_links'] as $_mod_link"> <option value="{$_mod_link['option']}">-{$_mod_link['value']}</option> </foreach> </select> <input type="submit" value="{$this->lang->words['jmp_go']}" class="input_submit alt" /> </fieldset> </form> <script type='text/javascript'> $('modform2').observe('submit', ipb.topic.submitTopicModeration ); </script> </div> </if> </if> <!-- REPUTATION FILTERS --> <if test="reputationFilter:|:$this->settings['reputation_enabled'] && $this->settings['reputation_show_content'] && $this->memberData['member_id'] != 0 && is_array($this->caches['reputation_levels'])"> <div id='reputation_filter' class='filter_bar rounded'> <span id='show_filters' class='clickable' style='display: none'>{$this->lang->words['rep_f_currently']} <if test="repFilterDefault:|: isset( $this->memberData['_members_cache']['rep_filter'] ) AND ( $this->memberData['_members_cache']['rep_filter'] == '*' || !is_int($this->memberData['_members_cache']['rep_filter']) )">{$this->lang->words['rep_f_viewing_all']} <else />{$this->lang->words['rep_f_hiding']} {$this->memberData['_members_cache']['rep_filter']} {$this->lang->words['rep_f_points']}.</if> {$this->lang->words['rep_f_threshold']}</span> <form id='filter_form' method="post" action="{parse url="" base="public"}"> <fieldset> <input type="hidden" name="app" value="forums" /> <input type="hidden" name="module" value="forums" /> <input type="hidden" name="section" value="topics" /> <input type="hidden" name="rep_filter" value="update" /> <input type="hidden" name="f" value="{$topic['forum_id']}" /> <input type="hidden" name="t" value="{$topic['tid']}" /> <input type="hidden" name="auth_key" value="{$this->member->form_hash}" /> <input type="hidden" name="st" value="{$this->request['st']}" /> <label for='rep_filter_select'>{$this->lang->words['rep_f_hide']}</label> <select name='rep_filter_set' id='rep_filter_select'> <option value='*' <if test="optSelectStar:|:isset( $this->memberData['_members_cache']['rep_filter'] ) AND $this->memberData['_members_cache']['rep_filter'] == '*'"> selected='selected'</if>>{$this->lang->words['rep_f_all_posts']}</option> <if test="repFilterOptions:|:is_array($this->caches['reputation_levels'])"> <foreach loop="reputation_levels:$this->caches['reputation_levels'] as $k => $v"> <option value='{$v['level_points']}'<if test="optRepFilterSelected:|:isset( $this->memberData['_members_cache']['rep_filter'] ) AND $v['level_points'] == $this->memberData['_members_cache']['rep_filter']"> selected='selected'</if>>{$v['level_points']} {$this->lang->words['rep_f_points']}</option> </foreach> </if> </select> <input type="submit" name="gobutton" value="{$this->lang->words['rep_f_update']}" class="input_submit alt" /> </fieldset> </form> </div> <script type='text/javascript'> $('show_filters').show(); </script> </if> <div class='moderation_bar rounded' id='topic_search_jump'> <form method='post' action='{$this->settings['base_url']}app=core&module=search&do=quick_search&search_filter_app[forums]=1' id='context_search' class='left'> <fieldset> <input type='hidden' name='type_2' value='topic' /> <input type='hidden' name='type_id_2' value='{$topic['tid']}' /> <label for='topic_search'>{$this->lang->words['search_topic']}</label> <input type='text' id='topic_search' name='search_term' class='input_text' size='20' tabindex='8' /> <input type='submit' class='input_submit alt' value='{$this->lang->words['search_topic_go']}' /> </fieldset> </form> <if test="forumJump:|:$forum['FORUM_JUMP']"> {$forum['FORUM_JUMP']} </if> </div> <!-- THREADED MODE --> <if test="threadedEnabled:|:$displayData['threaded_mode_enabled'] == 1"> <br /> <div class='topic_controls'> {$topic['threaded_pages']} <ul class='topic_buttons'> <if test="threadedNewTopic:|:$forum['_user_can_post']"> <li><a href='{parse url="module=post&section=post&do=new_post&f={$forum['id']}" base="publicWithApp"}' title='{$this->lang->words['start_new_topic']}'>{parse replacement="topic_icon"} {$this->lang->words['start_new_topic']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_start']}</span></li> </if> <if test="threadedClosed:|:$topic['state'] == 'closed'"> <li class='closed'> <if test="threadedClosedLink:|:$displayData['reply_button']['url']"> <a href='{$displayData['reply_button']['url']}'>{parse replacement="lock_icon"} {$this->lang->words['top_locked_reply']}</a> <else /> <span>{parse replacement="lock_icon"} {$this->lang->words['top_locked']}</span> </if> </li> <else /> <if test="threadedReply:|:$displayData['reply_button']['image']"> <if test="threadedReplyLink:|:$displayData['reply_button']['url']"> <li><a href='{$displayData['reply_button']['url']}' title='{$this->lang->words['add_a_reply']}'>{parse replacement="reply_icon"} {$this->lang->words['topic_add_reply']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_reply']}</span></li> </if> </if> </if> </ul> </div> <h2 class='maintitle'>{$this->lang->words['threads']}</h2> <div class='generic_bar'></div> <div class='threaded_view general_box'> {$topic['_threaded_posts']} </div> {$topic['threaded_pages']} </if> <ul class='topic_jump right clear'> <li class='previous'><a href='{parse url="showtopic={$topic['tid']}&view=old" seotitle="{$topic['title_seo']}" template="showtopic" base="public"}'>← {$this->lang->words['previous_topic']}</a></li> <li><strong><a href='{parse url="showforum={$forum['id']}" base="public" seotitle="{$forum['name_seo']}" template="showforum"}' title='Return to {$forum['name']}'>{$forum['name']}</a></strong></li> <li class='next'><a href='{parse url="showtopic={$topic['tid']}&view=new" seotitle="{$topic['title_seo']}" template="showtopic" base="public"}'>{$this->lang->words['next_topic']} →</a></li> </ul> <if test="topicSharing:|:$this->memberData['member_id']"> <h3 class='topic_share left'>{$this->lang->words['topic_share']}</h3> <ul class='topic_share left'> <li><a href='{parse url="app=forums&module=extras&section=forward&f={$forum['id']}&t={$topic['tid']}" base="public"}' title='{$this->lang->words['topic_email_title']}'>{$this->lang->words['topic_email']}</a></li> <li><a href='{parse url="app=forums&module=forums&section=printtopic&client=printer&f={$forum['id']}&t={$topic['tid']}" base="public"}' title='{$this->lang->words['topic_print_title']}'>{$this->lang->words['topic_print']}</a></li> <li><a href='{parse url="app=forums&module=forums&section=printtopic&client=choose&f={$forum['id']}&t={$topic['tid']}" base="public"}' title='{$this->lang->words['topic_download_title']}'>{$this->lang->words['topic_download']}</a></li> </ul> </if> <!-- BOTTOM BUTTONS --> <div class='topic_controls clear'> {$topic['SHOW_PAGES']} <ul class='topic_buttons'> <if test="finalNewTopic:|:$forum['_user_can_post']"> <li><a href='{parse url="module=post&section=post&do=new_post&f={$forum['id']}" base="publicWithApp"}' title='{$this->lang->words['start_new_topic']}'>{parse replacement="topic_icon"} {$this->lang->words['start_new_topic']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_start']}</span></li> </if> <if test="finalClosed:|:$topic['state'] == 'closed'"> <li class='closed'> <if test="finalClosedLink:|:$displayData['reply_button']['url']"> <a href='{$displayData['reply_button']['url']}' accesskey='r'>{parse replacement="lock_icon"} {$this->lang->words['top_locked_reply']}</a> <else /> <span>{parse replacement="lock_icon"} {$this->lang->words['top_locked']}</span> </if> </li> <else /> <if test="finalReply:|:$displayData['reply_button']['image']"> <if test="finalReplyLink:|:$displayData['reply_button']['url']"> <li><a href='{$displayData['reply_button']['url']}' title='{$this->lang->words['add_a_reply']}' accesskey='r'>{parse replacement="reply_icon"} {$this->lang->words['topic_add_reply']}</a></li> <else /> <li class='disabled'><span>{$this->lang->words['top_cannot_reply']}</span></li> </if> </if> </if> </ul> </div> <hr /> <if test="fastReply:|:$displayData['fast_reply'] != 'unavailable' && $displayData['reply_button']['url']"> <br /> <div id='fast_reply' style='display: {$displayData['fast_reply']}'> <h3 class='maintitle'>{$this->lang->words['qr_title']}</h3> <div class='generic_bar'></div> <div class='general_box alt'> <form action="{parse url="" base="publicWithApp"}" method="post"> <fieldset> <input type="hidden" name="app" value="forums" /> <input type="hidden" name="module" value="post" /> <input type="hidden" name="section" value="post" /> <input type="hidden" name="do" value="reply_post_do" /> <input type="hidden" name="f" value="{$forum['id']}" /> <input type="hidden" name="t" value="{$topic['tid']}" /> <input type="hidden" name="st" value="{$this->request['st']}" /> <input type="hidden" name="auth_key" value="{$this->member->form_hash}" /> <input type="hidden" name="fast_reply_used" value="1" /> <input type="hidden" name="enableemo" value="yes" /> <input type="hidden" name="enablesig" value="yes" /> <if test="$this->memberData['auto_track']"> <input type="hidden" name="enabletrack" value="1" /> </if> <if test="is_array($topic['_fastReplyStatusMessage']) AND count($topic['_fastReplyStatusMessage']) AND strlen($topic['_fastReplyStatusMessage'][0])"> <div class='message'>{parse expression="implode( '<br />', $topic['_fastReplyStatusMessage'])"}</div> </if> {parse template="editorShell" group="editors" params="'fast-reply', 'Post', '', 1"} </fieldset> <fieldset class='submit'> <input type='submit' name="submit" class='input_submit' value='{$this->lang->words['qr_post']}' tabindex='0' accesskey='s' id='submit_post' /> <input type='submit' name="preview" class='input_submit alt' value='{$this->lang->words['qr_more_opts']}' tabindex='0' id='full_compose' /> </fieldset> </form> </div> </div> <script type="text/javascript"> //<![CDATA[ if( $('fast-reply_textarea') ){ $('fast-reply_textarea').addClassName('unloaded_editor').setStyle('height: 70px'); $('fast-reply_textarea').value = "{$this->lang->words['editor_unloaded_atm']}"; } if( $('fast-reply_toolbar_1') ){ $('fast-reply_toolbar_1').hide(); } if( $('fast-reply_toolbar_2') ){ $('fast-reply_toolbar_2').hide(); } if( $('fast-reply_resizer') ){ $('fast-reply_resizer').hide(); } var removeTip = function(e){ if( $('fast-reply_textarea').hasClassName('unloaded_editor') ){ $('fast-reply_textarea').value=''; } }; $('full_compose').observe( 'click', removeTip ); $('submit_post').observe( 'click', removeTip ); in_use = 0; ipb.editor_values.set( 'emoticons', $H({ {parse expression="IPSLib::fetchEmoticonsAsJson()"} }) ); ipb.vars['emoticon_url'] = "{$this->settings['emoticons_url']}"; $('fast-reply_textarea').observe( 'focus', function(e){ if( !in_use ) { if( $('fast-reply_toolbar_1') ){ $('fast-reply_toolbar_1').show(); } if( $('fast-reply_toolbar_2') ){ $('fast-reply_toolbar_2').show(); } if( $('fast-reply_resizer') ){ $('fast-reply_resizer').show(); } $('fast-reply_textarea').removeClassName('unloaded_editor').value = ''; ipb.editors[ 'fast-reply' ] = new ipb.editor( 'fast-reply', USE_RTE ); $( ipb.editors['fast-reply'] ).resize_to( 250 ); try { ipb.editors[ 'fast-reply' ].editor_window.focus(); } catch(err) { } in_use = 1; } }); //]]> </script> </if> <!-- ACTIVE USERS --> <if test="topicActiveUsers:|:is_array( $displayData['active_users'] ) AND count( $displayData['active_users'] )"> <div id='topic_stats' class='statistics general_box clear clearfix'> <div id='topic_active_users' class='active_users'> <h2> {parse expression="sprintf( $this->lang->words['active_users_title'], ($displayData['active_users']['members'] + $displayData['active_users']['guests'] + $displayData['active_users']['anon'] ) )"}<br /> <span class='de//=========================================================================== Link to comment Share on other sites More sharing options...
Michael Posted July 9, 2009 Share Posted July 9, 2009 How about instead of posting that entire template, you just talk about what changes you'd make to it? It's hard to tell specifically what you're changing given that wall of code. Link to comment Share on other sites More sharing options...
Peter F. Posted July 9, 2009 Author Share Posted July 9, 2009 My apologies, I was merely showing what I had done so that it could be copy pasted directly into the file if needs be. Ok what I have done there is taken the template inside the foreach loop and placed it inside a template function postViewTemplate($forum, $topic, $post, $displayData) Currently the section of the topicViewTemplate dealing with posts is structured like so: This change should allow hook authors to extract post specific data from each post iteration to use in their hooks.<if test="hasPosts:|:is_array( $post_data ) AND count( $post_data )"> <!-- skinnote: Posts by ignored users are not hidden, check _ignored --> <foreach loop="post_data:$post_data as $pid => $post"> . . Lots of post template stuff in here . . </foreach> </if> <!-- MOD LINKS --> and I changed it to this <if test="hasPosts:|:is_array( $post_data ) AND count( $post_data )"> <!-- skinnote: Posts by ignored users are not hidden, check _ignored --> <foreach loop="post_data:$post_data as $pid => $post"> {$this->postViewTemplate($forum, $topic, $post, $displayData)} </foreach> </if> <!-- MOD LINKS --> where the postViewTemplate function is structured like so: //=========================================================================== // Name: postViewTemplate //=========================================================================== function postViewTemplate($forum, $topic, $post, $displayData) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF . . Lots of post template stuff in here . . EOF; //--endhtml--// return $IPBHTML; } Link to comment Share on other sites More sharing options...
Martin A. Posted July 10, 2009 Share Posted July 10, 2009 [quote name='peaderfi' date='09 July 2009 - 04:05 AM' timestamp='1247105132' post='1823007'] With the foreach template hooks though you still run into the problem that you can't access any of the data that is actually used in the post itself. For example using the "foreach hook" I am not able to access the $post variable that is used in the topicViewTemplate which contains the post specific data I'm looking to use. Nor would using the "foreach hook" allow me to place the data where I want it to go in each post unless hooks are given access to the post that has been generated by the template, in which case regex could be used to perform replacements or insertions to each post on the fly using the foreach hook. But from my examinations of the IPB code this is not what happens. From what I can see this is what happens: Additionally there is no way, that I can see, at present to make an "if hook" run separately for each post, even if the "foreach hook" is used, and thus no way for IPB to differentiate between the hook being placed in post #1 and the hook being placed in post #2. I was thinking in lines of this. Lets say you have the following foreach block Then lookForForeachHooks() would look for hooks used in foreachs, and pass $post to a function in that hook while it's iterating trough $posts. IPB parses the topicViewTemplate for the topic. IPB then checks to see if there are any hook points that will fit in. If there are IPB parses those hook points separately and places them into the hook point. IPB then removes any hooks points that have not been used and displays the topic<foreach loop="$posts as $post"> /* Do the template parsing stuff here */ </foreach> When that's parsed from IPB HTML logic to PHP, if would be this foreach( $posts as $post ) { $post = $this->lookForForeachHooks( $post ); /* Do the template here */ ] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.