我为phpBB制作了一些BBcode,使用户可以以特定标签发布flickr图片。
每个帖子中的照片div都需要是唯一的,并且这些图片会随着帖子的加载而加载。
关于唯一的DIV,我无法找到一种方法,在插入BBcode的位置插入具有唯一名称的元素,然后再加载图片。看起来我不能在BBcode中使用PHP或模板标签。如果我能够轻松地从帖子ID和flickr标记创建唯一的照片元素,那就太好了。哦,我不能触及模板。所有内容都必须在BBcode中完成。 所以,这是我如何创建唯一标识符的方法:
或者...上面有一个带有唯一文章ID的元素,我可能可以使用它:
甚至
可能会更好。
关于唯一的DIV,我无法找到一种方法,在插入BBcode的位置插入具有唯一名称的元素,然后再加载图片。看起来我不能在BBcode中使用PHP或模板标签。如果我能够轻松地从帖子ID和flickr标记创建唯一的照片元素,那就太好了。哦,我不能触及模板。所有内容都必须在BBcode中完成。 所以,这是我如何创建唯一标识符的方法:
var flickrUser = "{URL}".split("/")[4];
var tag = "{URL}".split("/")[6];
var photoDIV = flickrUser + "-" + "tag";
或者...上面有一个带有唯一文章ID的元素,我可能可以使用它:
<div id="p61789" class="post bg2">
我尝试过
var postnumber=$(this).closest('div[class^="post"]').attr('id');
但它似乎总是返回页面上第一个匹配的 div,而不是最接近 BBcode 点的 div。这个元素在下面的两个 "div" 中。
<div class = "content">
在用户发布区域下面有:
<div id="sig61789" class="signature">
我完全陷入困境的地方是,当我在没有$(this)链接参考的情况下,如何导航到prev()、closest()、parent()或其他任何地方。
所以,像这样的东西不应该行得通吗:
$(this).prev('content').html('<ul class="thumbs" id=photoDIV></ul>');
甚至
可能会更好。
$(this).html('<ul class="thumbs" id=photoDIV></ul>');
工作原理?每次我觉得我理解jquery了,它又变得模糊不清...
编辑:为Pointy添加更多细节:
<div id="p63167" class="post bg2 online">
<div class="inner">
<span class="corners-top">
<span></span>
</span>
<div class="postbody">
<ul class="profile-icons">
<li class="edit-icon">
<a href="posting.php" title="Edit post">
<span>Edit post</span>
</a>
</li>
<li class="delete-icon">
<a href="posting.php" title="Delete post">
<span>Delete post</span>
</a>
</li>
<li class="report-icon">
<a href="report.php" title="Report this post">
<span>Report this post</span>
</a>
</li>
<li class="info-icon">
<a href="mcp.php" title="Information">
<span>Information</span>
</a>
</li>
<li class="quote-icon">
<a href="posting.php" title="Reply with quote">
<span>Reply with quote</span>
</a>
</li>
</ul>
<h3 class="first">
<a href="#p63167">Re: Testing new bbcode - ignore</a>
</h3>
<p class="author">
<a href="viewtopic.php">
<img src="" alt="Post" title="Post" />
</a>by
<strong>
<a href="memberlist.php">xxx</a>
</strong>» 13 Jun 2011 14:33</p>
<div class="content">
<script></script>
<ul id="cbox" class="thumbs"></ul>
</div>
<div id="sig63167" class="signature"></div>
</div>
</div>
</div>