简体   繁体   English

使行可单击以将您带到链接

[英]Making a row clickable to take you to a link

I've made some CSS modifications to it already and now I need to make one programming modification. 我已经对其进行了一些CSS修改,现在我需要进行一次编程修改。 I'm a C# guy so this PHP is throwing me a little curve ball. 我是C#专家,所以这个PHP给我丢了一个曲线球。

Here is the part I would like to modify: 这是我要修改的部分:

<li class="row">
            <!-- EVENT forumlist_body_forum_row_prepend -->
            <dl class="icon {forumrow.FORUM_IMG_STYLE}">
                <dt title="{forumrow.FORUM_FOLDER_IMG_ALT}">
                    <!-- IF forumrow.FORUM_IMAGE --><div class="forum-image">{forumrow.FORUM_IMAGE}</div><!-- ENDIF -->
                    <a href="{forumrow.U_VIEWFORUM}" class="icon-link"></a>

                    <!-- IF .forumrow.subforum and forumrow.S_LIST_SUBFORUMS -->
                    <div class="dropdown-container dropdown-button-control">
                        <span title="{forumrow.L_SUBFORUM_STR}" class="dropdown-trigger"></span>
                        <div class="dropdown hidden">
                            <div class="dropdown-contents">
                            <!-- EVENT forumlist_body_subforums_before -->
                            <strong>{forumrow.L_SUBFORUM_STR}{L_COLON}</strong>
                            <!-- BEGIN subforum -->
                                <a href="{forumrow.subforum.U_SUBFORUM}" class="subforum<!-- IF forumrow.subforum.S_UNREAD --> unread<!-- ELSE --> read<!-- ENDIF -->" title="<!-- IF forumrow.subforum.UNREAD -->{L_UNREAD_POSTS}<!-- ELSE -->{L_NO_UNREAD_POSTS}<!-- ENDIF -->">{forumrow.subforum.SUBFORUM_NAME}</a>
                            <!-- END subforum -->
                            <!-- EVENT forumlist_body_subforums_after -->
                            </div>
                        </div>
                    </div>
                    <!-- ENDIF -->
                    <div class="list-inner">
                        <a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a>
                        <span class="forum-description">{forumrow.FORUM_DESC}</span>
                        <!-- IF forumrow.MODERATORS -->
                            <!--<br /><span class="forum-moderators"><strong>{forumrow.L_MODERATOR_STR}{L_COLON}</strong> {forumrow.MODERATORS}</span>-->
                        <!-- ENDIF -->
                    </div>
                </dt>

                <!-- IF forumrow.CLICKS -->
                    <dd class="redirect"><span>{L_REDIRECTS}{L_COLON} {forumrow.CLICKS}</span></dd>
                <!-- ELSEIF not forumrow.S_IS_LINK -->
                    <dd class="forum-stats<!-- IF forumrow.S_UNREAD_FORUM --> unread<!-- ENDIF -->"><span>
                        <!-- IF forumrow.LAST_POST_TIME -->(<dfn>{L_TOPICS}{L_COLON}</dfn> {forumrow.TOPICS} | <dfn>{L_POSTS}{L_COLON}</dfn>{forumrow.POSTS})
                        <!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}" title="<!-- IF forumrow.S_UNREAD_FORUM -->{L_UNREAD_POSTS}<!-- ELSE -->{L_NO_UNREAD_POSTS}<!-- ENDIF -->">{LAST_POST_IMG}</a><!-- ENDIF --><!-- ELSE -->{L_NO_POSTS}<!-- ENDIF -->
                        <!-- EVENT forumlist_body_last_post_title_prepend -->
                    </span></dd>

                    <dd class="mcp-status"><span>
                        <!-- IF forumrow.U_UNAPPROVED_TOPICS -->
                            <a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a>
                        <!-- ELSEIF forumrow.U_UNAPPROVED_POSTS -->
                            <a href="{forumrow.U_UNAPPROVED_POSTS}">{UNAPPROVED_POST_IMG}</a>
                        <!-- ENDIF -->
                        </span>
                    </dd>
                <!-- ENDIF -->
            </dl>
            <!-- EVENT forumlist_body_forum_row_append -->
        </li>

I would like if the "row" is clicked for it to take you to the forum. 我希望单击"row"将其带到论坛。 Right now only if the title/header is clicked will it take you to the forum. 现在,只有单击标题/标题,它才会带您进入论坛。

Which I believe is this line: 我相信这条线是:

<a href="{forumrow.U_VIEWFORUM}" class="icon-link"></a>

Here is a demo of how the default template works: 这是默认模板如何工作的演示:

https://www.phpbb.com/customise/db/style/pbtech/demo/3.1 The only difference I have made from the demo is those forum "blocks" are now changed to take up 100% width instead of 33.3% . https://www.phpbb.com/customise/db/style/pbtech/demo/3.1我从演示中获得的唯一区别是,这些forum "blocks"现在已更改为占用100% width而不是33.3% 100% width I'd like it so if you click anywhere on the forum "block/row" it takes you to the forum. 我想要这样,如果您在论坛的任何位置单击“阻止/行”,它将带您进入论坛。

This cannot be achieved with PHP. 使用PHP无法实现。 It could be achieved with a small JavaScript snippet on the front end. 可以通过在前端使用一个小的JavaScript代码段来实现。

<script type="text/javascript">
$(document).ready( function(){

    $("li.row").click( function(){
        var anchor = $(this).find("a:first");
        anchor.trigger("click"); // OR
        window.location = anchor.attr("href");
    });
});
</script>

What this does is attaches an event handler to any clicks on li.row . 这是将事件处理程序附加到对li.row任何单击上。 It finds the link within and either triggers click to it, or uses its href property to change browser window location URL. 它找到其中的链接并触发对其的单击,或使用其href属性更改浏览器窗口的位置URL。

This requires a JavaScript library called jQuery which appears to already be in use on your demo template. 这需要一个名为jQuery的JavaScript库,该库似乎已在您的演示模板上使用。 The code block above would need to be included BELOW the <script> include tag for jQuery. 上面的代码块需要包含在jQuery的<script> include标签之下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM