All pastes #1036148 Raw Edit

Xaraya Article Preview Search Bl

public text v1 · immutable
#1036148 ·published 2008-06-01 19:38 UTC
rendered paste body
<xar:comment>
    get the ptid from the aid passed in the URL and pre-filter search results?
    need aid for the article title to search on anyway...
</xar:comment>
<xar:set name="dummy">xarVarFetch('aid', 'id', $aid, NULL, XARVAR_NOT_REQUIRED)</xar:set>
<xar:set name="dummy">xarVarFetch('ptid', 'id', $ptid, NULL, XARVAR_NOT_REQUIRED)</xar:set>
<xar:set name="dummy">xarVarFetch('title', 'str', $title, NULL, XARVAR_NOT_REQUIRED)</xar:set>

<xar:if condition="$aid gt 0">
    <xar:set name="articleinfo">xarModAPIFunc('articles','user','get',array('aid'=>$aid))</xar:set>
    <xar:set name="title">$articleinfo['title']</xar:set>
    <xar:set name="ptid">$articleinfo['pubtypeid']</xar:set>
</xar:if>

<xar:if condition="!stristr($title, ' ')">
    <xar:set name="q">$title</xar:set>
<xar:else />

    <xar:set name="q_words">str_word_count($title, 1)</xar:set>

    <xar:set name="q_array">array()</xar:set>
    <xar:foreach in="$q_words" value="$word">
        <xar:if condition="strlen($word) gt 4">
            <xar:set name="dummy">$q_array[] = $word</xar:set>
        </xar:if>
    </xar:foreach>
    <xar:if condition="count($q_array) gt 0">
        <xar:set name="q">implode(" ", $q_array)</xar:set>
    <xar:else />
        <xar:set name="q">$title</xar:set>
    </xar:if>
</xar:if>

<xar:if condition="$content_type eq 'html' and $custom_format eq ''">
    <div>#$content_text#</div>
</xar:if>
<xar:if condition="!empty($q)">
    <xar:set name="args">array('extrainfo' => array('q' => $q, 
                                                    'module' => "search", 
                                                    'ptid' => $ptid,
                                                    'search' => 1,
                                                    'template' => "block"),
                                 )</xar:set>
    <xar:set name="articles">xarModFunc('articles','user','search', $args)</xar:set>
    #$articles#
</xar:if>