Hello,
I'm currently building my custome front page: http://alphaflight.net/showwiki/
I would like to add in a search box, like is seen on the default front page. What code do I need to add a search field to a page?
Printable View
Hello,
I'm currently building my custome front page: http://alphaflight.net/showwiki/
I would like to add in a search box, like is seen on the default front page. What code do I need to add a search field to a page?
You'll need to use HTML on the page, so HTML needs to be allowed for the forum the page is saved in. If you do that, you definitely want to use forum permissions to lock down who's allowed to edit the page.
Gotcha. since this page is in my content namespace, I'd have to make all my wiki allow HTML, which I'm not fond of the idea of; even though only site members can post/edit...How does the "special" page allow a search field? If it's outside the namespace, how can I make my custom front page so?
If I were to allow HTML, what is the code that the default page uses to put in the search field?
you can also enable and add the Vbulletin sidebar, and put a wiki only search bar in it, like i did on http://www.birthright.net/forums/showwiki.php
you will need a mod from vbulletin.org (sidebar everywhere)
http://www.vbulletin.org/forum/showthread.php?t=233871
then add a custom block through your vbulletin control panel (forums & mods -> forum block manager)
create a new block with
then go to your styles and add a new template called: block_wikisearchCode:$templater = vB_Template::create('block_wikisearch');
$content = $templater->render();
return $content;
put the folowing code in it:
if you want to let it show on wiki pages only, check the sidebar everywhere settingsCode:<!-- Search Box -->
<form action="search.php?do=process" method="post" id="searchform">
<input type="hidden" name="s" value="" />
<input type="hidden" name="do" value="process" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input name="contenttype" value="VaultWiki_VaultArticle" type="hidden">
<input id="keyword" class="textbox" name="query" tabindex="1" value="" type="text">
<input class="button" value="Go" type="submit">
<br />
<label><input type="checkbox" name="titleonly" value="1" class="searchtype" style="margin: 5px 0 0 5px;" /> Search Titles Only</label>
</form>
</form>
<!-- /Search Box -->
Thanks Lord Doys,
I had no issues with installing the product and creating the block, but I'll be darned if I can figgure out how to get the sidebar to appear at all on the wiki...I tried hunting through the wiki templates to add the strings listed in the install instructions for "Instructions for custom pages" but I can't find the strings they want found...
How did you get it to show on your wiki?
hmm i cant remember doing something special about it.. its been a while :)
the custom pages is only for php/hml files that dont belong to the vbulletin framework. i only use that on my interactive map but not for the wiki.
nor can i see any wiki templates changed..
i will have to look into it further
ah i found it :)
i created a plugin under (admincp -> plugins & prods -> add new plugin)
by the looks of it, i "linked" it to the member sidebar, so you can use the member show/hide option in the ESB options to turn it of and on
product: Everywhere Sidebar
Hook location: vault_article_complete (VaultWiki)
title: wiki_sidebar
execution order: 5
plugin php code:
Code:if ($bbandSBactive and $vbulletin->options['esidebar_memberlist']){
require_once(DIR . '/includes/class_block.php');
$show_sidebar = false;
$blockmanager = vB_BlockManager::create($vbulletin);
$sidebar = $blockmanager->getSidebarHTML();
if ($sidebar)
{
$show_sidebar = true;
if (function_exists(rebuild_sidebar))$sidebar=rebuild_sidebar($blockmanager,$sidebar);
$templater = vB_Template::create('sidebarext_temp');
$templater->register('sidebar', $sidebar);$templater->register('show_sidebar', $show_sidebar);$templater->register('button_top_sidebar', intval($vbulletin->options['esidebar_button_top']));$templater->register('width_sidebar', intval($vbulletin->options['esidebar_width']));$templater->register('margin_sidebar', intval($vbulletin->options['esidebar_width'])+20);
$template_hook['sidebarext_temp']=$templater->render();
$sidebarext_add = "' . \$template_hook['sidebarext_temp'] . '";
$sidebarext_search = '/\' \. \$footer \. \'/';
$sidebarext_replace = $sidebarext_add . "' . \$footer . '";
$memberlistSIDEBAR = preg_replace($sidebarext_search, $sidebarext_replace, $vbulletin->templatecache['vault_article_main']);
$sidebarext_search = '/\' \. \$navbar \. \'/';
$sidebarext_add ='<div id="content_container"><div id="content">';
if($vbulletin->options['sidebarposition']==0)$sidebarext_add ='<div id="content_container" class="contentright"><div id="content">';
$sidebarext_replace = "' . \$navbar . '" . $sidebarext_add;
$memberlistSIDEBAR = preg_replace($sidebarext_search, $sidebarext_replace, $memberlistSIDEBAR);
$vbulletin->templatecache['vault_article_main'] = $memberlistSIDEBAR;
}
}
i now remember why i did it this way. I didnt want to hack 2 different products in case they are updated and things will be overwritten
Thanks again for helping me out with this LD, I tried made the plugin as you directed, it didn't go over too well. I got this when loading the wiki:
Code:Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 15
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 15
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 15
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 18
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 18
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/waloraweb011/b1777/moo.benjaminlwells/vault/tab/article.php(712) : eval()'d code on line 18
Warning: preg_replace() [function.preg-replace]: Unknown modifier 'd' in [path]/vault/tab/article.php(712) : eval()'d code on line 17
Parse error: syntax error, unexpected T_STRING in /hermes/waloraweb011/b1777/moo.benjaminlwells/includes/class_core.php(4627) : eval()'d code on line 1
I have had some issues copying code blocks from this site as wel.
I found out if quote the msg with the code, and select the code from the quoted msg.
If that dont work, pm your email and ill send a txt file
ah, perfect that did it! Now you've got me wondering how you made the block for recent wiki changes? Is it custom code, or did you use the preset to look at the namespace forum?
Fixed the bug with the backslashes inside the code block. It was a bug in VaultWiki, so your sites will have it too: https://www.vaultwiki.org/issues/2639/
create a block in the forums block manager (same as you did before)
i called it: recent wiki changes
php
put the following code in the content.
you probably have to replace ALL the text with vb3_ with your own prefix code of your vbulletin tables
then create a new template in the style manager called: block_wikichangesCode:global $db, $vbphrase, $threadinfo, $post, $stylevar, $show;
$threads= $db->query_read_slave("
SELECT thread.title, thread.forumid, thread.threadid, revision.revisionid, revision.reason as reason,
revision.dateline, revision.username as postusername, thread.lastpost AS threadlastpost,
thread.lastposterid, forum.title_clean as forumtitle, user.*, avatar.avatarpath,
NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,
customavatar.width AS avwidth,customavatar.height AS avheight
FROM (
select * from `vb3_vault_revision` order by dateline DESC
) AS revision
LEFT JOIN vb3_thread AS thread ON (thread.threadid = revision.threadid)
INNER JOIN vb3_forum AS forum ON(forum.forumid = thread.forumid)
LEFT JOIN vb3_user AS user ON (user.userid = revision.userid)
LEFT JOIN vb3_avatar AS avatar ON(avatar.avatarid = user.avatarid)
LEFT JOIN vb3_customavatar AS customavatar ON(customavatar.userid = user.userid)
group by thread.title
order by revision.dateline DESC
LIMIT 10
");
while ($thread = $this->registry->db->fetch_array($threads))
{
//echo "title: ".$thread['title'] ."<br>";
// still need to censor the title
$thread['title'] = fetch_censored_text($thread['title']);
$thread['date'] = vbdate($this->registry->options['dateformat'], $thread['dateline'], true);
$thread['time'] = vbdate($this->registry->options['timeformat'], $thread['dateline']);
$thread['lastpostdate'] = vbdate($this->registry->options['dateformat'], $thread['threadlastpost'], true);
$thread['lastposttime'] = vbdate($this->registry->options['timeformat'], $thread['threadlastpost']);
// get avatar
$this->fetch_avatarinfo($thread);
$threadarray[$thread['threadid']] = $thread;
}
foreach ($threadarray as $key => $thread)
{
//echo "<br> - title: ". $threadarray[$key]['title'];
$threadarray[$key]['url'] = fetch_seo_url('thread', $thread);
$threadarray[$key]['newposturl'] = fetch_seo_url('thread', $thread, array('goto' => 'newpost'));
$threadarray[$key]['lastposturl'] = fetch_seo_url('thread', $thread, array('p' => $thread['lastpostid'])) .
'#post' . $thread['lastpostid'];
$threadarray[$key]['title'] = fetch_trimmed_title($thread['title'], $this->config['threads_titlemaxchars']);
}
$templater = vB_Template::create('block_wikichanges');
$templater->register('threads', $threadarray);
return $templater->render();
$db->free_result($threads);
unset($threadarray );
with the following code
then in the everywhere sidebar you can show hide it where ever you likeCode:<ul id="block_wikichanges_{vb:raw blockinfo.blockid}" >
<vb:each from="threads" key="threadid" value="thread">
<li class="<vb:if condition="!$vboptions['avatarenabled']">no</vb:if>avatarcontent floatcontainer widget_post_bit">
<div class="widget_post_userinfo">
<vb:if condition="$vboptions['avatarenabled']">
<div class="cms_widget_post_useravatar widget_post_useravatar">
<a class="smallavatar comments_member_avatar_link" href="{vb:link member, {vb:raw thread}}">
<vb:if condition="$thread['showavatar']">
<img width="30" title="" src="{vb:raw thread.avatarurl}" alt=""/>
<vb:else />
<img width="30" title="" src="{vb:stylevar imgdir_misc}/unknown.gif" alt=""/>
</vb:if>
</a>
</div>
</vb:if>
</div>
<div class="smallavatartext widget_post_comment<vb:if condition="!$vboptions['avatarenabled']">_noavatar</vb:if>">
<h5 class="widget_post_header"><a href="{vb:raw thread.url}" class="title">{vb:raw thread.title}</a></h5>
<div class="meta">
<vb:if condition="$threadstype == 0">Edited by <a href="{vb:link member, {vb:raw thread}}">{vb:raw thread.postusername}</a> {vb:stylevar dirmark}<vb:if condition="$thread['reason']"><br />(Reason: {vb:raw thread.reason})</vb:if>
<br />{vb:raw thread.date}<vb:if condition="!$show['detailedtime']">, <span class="time">{vb:raw thread.time}</span></vb:if> {vb:rawphrase in_x, {vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}, {vb:raw thread.forumtitle}}
<vb:else />
{vb:rawphrase last_post_by} <a href="{vb:link member, {vb:raw thread}, null, 'lastposterid', 'lastposter'}">{vb:raw thread.lastposter}</a> {vb:stylevar dirmark}({vb:rawphrase x_replies, {vb:raw thread.replycount}})
<br />
{vb:raw thread.lastpostdate}<vb:if condition="!$show['detailedtime']">, <span class="time">{vb:raw thread.lastposttime}</span></vb:if> {vb:rawphrase in_x, {vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}, {vb:raw thread.forumtitle}}
</vb:if>
</div>
</div>
</li>
</vb:each>
</ul>
that should do it
oh i put the cache time of the block on 60 minutes, so it doesnt run too often
That's a good idea, that query is expensive (it requires a full scan of a potentially large vault_revision table). If you break it up into two queries, you can perform the scan on a much smaller table.
Use the collected datelines to:Code:SELECT lastmodified AS dateline FROM vb3_vault_article WHERE pending = 0
Hope this helps; this is essentially how we build the Recent Changes page to avoid massive scans.Code:SELECT ... FROM vb3_vault_revision AS revision
...
WHERE revision.dateline IN (collected_datelines)
Also, if you can and know how to package product files, it would be great if you can release this as a mod in our modifications forum.
You guys rock. I'll play around with that tomorrow. I have my boy home from school for the Holiday, and my wife at work, so I might not get a chance to dig in, I'll let you know where I get with it!