<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>logIt &#187; search</title>
	<atom:link href="https://lakm.us/logit/tag/search/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>MicroBlogger Add Search Feature (1)</title>
		<link>https://lakm.us/logit/2009/10/microblogger-add-search-feature-1/</link>
		<comments>https://lakm.us/logit/2009/10/microblogger-add-search-feature-1/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 05:27:33 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[OpenMicroBlogger]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://localhost/it/?p=88</guid>
		<description><![CDATA[This is mainly about view of custom search page (not about searching itself). Adding &#8220;Search&#8221; To Main Link Tabs Changes to file under /app/omb/plugins/ wp.php security.php In wp.php: Adding $links&#91;'Search'&#93; = $request-&#62;url_for&#40;'search'&#41;; between &#8216;Personal&#8217; and &#8216;Profile&#8217; would bring out the &#8216;Search&#8217; tab in main link-tabs. In security.php Adding function security_init&#40;&#41; &#123; ... $request-&#62;connect&#40; 'search' &#41;; [...]]]></description>
				<content:encoded><![CDATA[<p>This is mainly about view of custom search page (not about searching itself).</p>
<p><strong>Adding &#8220;Search&#8221; To Main Link Tabs</strong></p>
<p>Changes to file under</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>omb<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<ol>
<li><code>wp.php</code></li>
<li><code>security.php</code></li>
</ol>
<p>In <strong><code>wp.php</code></strong>:</p>
<p>Adding</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Search'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url_for</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>between &#8216;Personal&#8217; and &#8216;Profile&#8217; would bring out the &#8216;Search&#8217; tab in main link-tabs.</p>
<p>In <strong><code>security.php</code></strong></p>
<p>Adding</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> security_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #339933;">...</span>
<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'search'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span></pre></div></div>

<p>would give the URI link if tab is clicked or hovered, that is: <code>http://<em>base_url</em>/<strong>?search</strong></code>.</p>
<p>Adding the search function would make the URI seek for the correlated viewing page</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$vars</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$vars</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'requested_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I create a viewing page then, under <code>/app/omb/<strong>view</strong>/</code> by the name <code>_search.html</code>.</p>
<p>However, the main theme won&#8217;t appear correctly. So, what I do is: add a controller in <code>/app/omb/<strong>controller</strong>/</code> with the name <code>search_posts.php</code> (an empty one for a start) and its view with the name <code>_search_posts.html</code> (inside <code>/app/omb/view/</code>). And then, add rendering to our previous search-function as in</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$vars</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$vars</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'requested_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base</span><span style="color: #339933;">;</span>
render<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;strong&gt;search_posts&lt;/strong&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As I&#8217;ll be incorporating databases issue later. The following search is adequate to show relevant results, plain with no links etc. It is the content of the current <code>_search_posts.html</code>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>environment<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authentication'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; width=&quot;770&quot; align=&quot;center&quot; style=&quot;margin-top: 30px;&quot;&gt;
&lt;tr&gt;
  &lt;td class=&quot;content&quot;&gt;
&lt;!-  &lt;form name=&quot;search&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;post&quot;&gt;
  &lt;form name=&quot;search&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> url_for<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;post&quot;&gt;
&nbsp;
    &lt;table cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; align=&quot;center&quot; width=&quot;500&quot;&gt;
    &lt;tr&gt;
      &lt;td height=&quot;40&quot; align=&quot;center&quot; colspan=&quot;2&quot;&gt;Please enter search&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td height=&quot;10&quot; colspan=&quot;2&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;170&quot; height=&quot;30&quot; align=&quot;right&quot;&gt;Search:&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;text&quot; maxlength=&quot;30&quot; name=&quot;search_&quot; value=&quot;&quot; style=&quot;width: 180px;&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr height=&quot;30&quot;&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; style=&quot;width: 180px; font-size: 10px; text-transform: uppercase; color: #003366; border: 1px solid #336699; background-color: #DDDDDD; padding: 3px;&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td height=&quot;10&quot; colspan=&quot;2&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #000088;">$link1</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;db_name&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;db_password&quot;</span><span style="color: #009900;">&#41;</span>
                 or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not connect to MySQL Server!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #339933;">@</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;omb_db&quot;</span><span style="color: #009900;">&#41;</span>
                 or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not select database!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$search_</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'search_'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT `title` , `id` FROM `posts` WHERE `title` LIKE '%<span style="color: #006699; font-weight: bold;">$search_</span>%'&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id_</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_row</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span>	<span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> url_for<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'resource'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$id_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$title</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;;
	&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2009/10/microblogger-add-search-feature-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
