vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   0-9 Link? (https://vborg.vbsupport.ru/showthread.php?t=212114)

Chadi 04-24-2009 11:37 PM

0-9 Link?
 
Hi folks. Need some little help here.

I have this mod I released that shows an ABC link nav menu for any specific forum the code is placed into.

https://vborg.vbsupport.ru/showthread.php?t=211939

The letters are linked like this:

<a rel="nofollow" href="http://www.yourdomain.com/forumdisplay.php?f=2&letter=a">A</a>

However, I'd like to add another link for numbers, but one link for any number: 0-9 and the link would be "#" not "0-9". Clicking the link would show all threads that begin with any number.

How can I achieve this?

Thanks.

Dead Eddie 04-25-2009 12:40 AM

I don't remember the code for that one, but at some point it hooked into a query with code like :

where $something = $letter

You'll need to do a conditional. If $letter == '#', your query is going to look like:

where $something BETWEEN 0 AND 9

I'm rebuilding my computer at the moment, so I didn't look at the mod. If you need more help, I'll reinstall that and take a second look. Also, I didn't test it, but in theory it should work. :)

Chadi 04-25-2009 01:27 AM

Thanks Eddie, but I don't know anything about programming past the assistance I was given. If you can figure it out, great thanks.

Dead Eddie 04-25-2009 02:50 AM

Untested...so try it on a test install first:

PHP Code:

if(isset($_GET['letter'])) {
    
$vbulletin->input->clean_GPC('r''letter''TYPE_STR);
    $letter = $db->escape_string($vbulletin->GPC['
letter']);

    if($letter == '
#') {
        
$hook " AND LEFT(thread.title, 1) BETWEEN 0 AND 9";
    }
    else {
        
$hook " AND LEFT(thread.title, 1) = '$letter'";
    }

    
$hook_query_where .= $hook;


Also, change the hook location in the file you've released to forumdisplay_query_threadid. That might solve some people's problems.

Chadi 04-25-2009 03:54 PM

Thanks, but what am I supposed to do with that code? Where does it go in the plugin file?

Dead Eddie 04-25-2009 05:25 PM

That's the updated code. It replaces what's in the plugin.

Also, I looked at the vbseo version, and it doesn't look like it was changed (except that it uses the correct hook). So, I'm wondering if there's either a change that didn't get picked up with the plugin, or if there really needs to be two different files.

Chadi 04-27-2009 03:30 AM

Thanks Ed. Still confused though.

The plugin now is this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="asp_thread_listing" active="1">
    <title>Thread Listing by Letter</title>
    <description>Listing of threads by the first letter of the title</description>
    <version>.1</version>
    <url />
    <versioncheckurl />
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>Add Where Letter</title>
            <hookname>forumdisplay_query</hookname>
            <phpcode><![CDATA[if(isset($_GET['letter'])){
$vbulletin->input->clean_GPC('r', 'letter', TYPE_STR);

$letter = $db->escape_string($vbulletin->GPC['letter']);

$hook_query_where .= " AND LEFT(thread.title, 1) = '$letter'";

}]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>

With your changes, is it supposed to look like this?

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="asp_thread_listing" active="1">
    <title>Thread Listing by Letter</title>
    <description>Listing of threads by the first letter of the title</description>
    <version>.1</version>
    <url />
    <versioncheckurl />
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>Add Where Letter</title>
            <hookname>forumdisplay_query</hookname>
            <phpcode><![CDATA[if(isset($_GET['letter'])) {
    $vbulletin->input->clean_GPC('r', 'letter', 'TYPE_STR);
    $letter = $db->escape_string($vbulletin->GPC['letter']);

    if($letter == '#') {
        $hook = " AND LEFT(thread.title, 1) BETWEEN 0 AND 9";
    }
    else {
        $hook = " AND LEFT(thread.title, 1) = '$letter'";
    }

    $hook_query_where .= $hook;
}]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>

I'll look into the vbseo thing again.

--------------- Added [DATE]1240808021[/DATE] at [TIME]1240808021[/TIME] ---------------

Just wanted to give you a heads up. Tested your code on a fresh install, non-vbseo. It always displayed all threads regardless of the letter clicked.

Dismounted 04-27-2009 05:57 AM

This line is incorrect (PHP Tags "fix" it):
$vbulletin->input->clean_GPC('r', 'letter', 'TYPE_STR);

Change it to:
PHP Code:

$vbulletin->input->clean_GPC('r''letter'TYPE_STR); 

Also, you should be using the Admin CP to generate the XML - it will remove any structural errors.

Dead Eddie 04-27-2009 11:20 AM

Quote:

Originally Posted by Dismounted (Post 1799770)
This line is incorrect:
PHP Code:

$vbulletin->input->clean_GPC('r''letter''TYPE_STR); 

Change it to:
PHP Code:

$vbulletin->input->clean_GPC('r''letter''TYPE_STR'); 

Also, you should be using the Admin CP to generate the XML - it will remove any structural errors.

Hm, I thought those TYPE_* were constants.

Quote:

Originally Posted by Chadi
Just wanted to give you a heads up. Tested your code on a fresh install, non-vbseo. It always displayed all threads regardless of the letter clicked.

You didn't make this change yet:

Quote:

Originally Posted by Myself
Also, change the hook location in the file you've released to forumdisplay_query_threadid. That might solve some people's problems.

If after making that change, you're still having problems, let me know. I should be able to install a test board today after work.

Chadi 04-27-2009 11:30 AM

Thanks, that works now.

I have two issues now:

One, I'm trying to figure out the proper code replacement for "forum-path" so a person can copy/past this into forumdisplay template to use the mod globally, not per forum (as I currently have it linked directly to one specific forum).

Example:

http://www.talkjesus.com/scriptural-bible-answers/?letter=a"

That's the link for letter A.

What should be the vbseo replacement for the forum title/path which for me here is "scriptural-bible-answers"? My vbseo panel shows

[forum_title]

I tried that like this, it did not work.

Talk Jesus | Christian Forums & Chat - Powered by vBulletin[forum_title]/?letter=a"

I even added a $ before [forum and still does not work. Just redirects back to home page.

Second question is, I'd like to add a 0-9 # link as well, before the letter A table column.

Example:
Scriptural Bible Answers - Talk Jesus | Christian Forums & Chat

So I want a link like this:

"0-9"

The question is, how can I properly link it so it shows all threads in that forum that begin with any number? What would the link code look like for a singe link for "0-9" or better yet, just "#"?

Thanks!

--------------- Added [DATE]1240864909[/DATE] at [TIME]1240864909[/TIME] ---------------

Would appreciate if anyone can help me on this, thanks.

I'm trying to make the template versions to one version, vbseo or non-vbseo since vbseo changes it automatically.

Regarding 0-9 numbered threads listing:

I tried this, does not work, shows no threads but I do have one thread that begins with a letter, "144,000..."

Code:

<a rel="nofollow" href="http://www.talkjesus.com/scriptural-bible-answers/?letter=#">#</a>
Regarding the template code:

I'm using this in a test forum (fresh install) without vbseo
Code:

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<td colspan="30" height="16" class="thead">
    <strong>Search topics by first letter</strong><tr align="center">
        <td class="alt1" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]">All</a></td>   
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=a">A</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=b">B</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=c">C</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=d">D</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=e">E</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=f">F</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=g">G</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=h">H</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=i">I</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=j">J</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=k">K</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=l">L</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=m">M</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=n">N</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=o">O</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=p">P</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=q">Q</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=r">R</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=s">S</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=t">T</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=u">U</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=v">V</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=y">Y</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=x">X</a></td>
        <td class="alt2" width="3%">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=y">Y</a></td>
        <td class="alt1" style="padding:5px;text-align:center">
        <a rel="nofollow" href="http://www.talkjesus.com/test/forumdisplay.php?f=$foruminfo[forumid]&letter=Z">Z</a></td>
    </tr>
</table>
<br />

I tried the same code above in my default install with vbseo enabled, does not work. Says invalid links.


All times are GMT. The time now is 05:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01194 seconds
  • Memory Usage 1,810KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete