12-16-2010, 12:53 PM
Requirement: XThreads
We will try to create a simple country list with XThreads. Maybe we can use this just for a country database/list, or discussion based on user's country.
Yeah, I know that maybe this is useless. But I just want to share it
Here is a simple way to do that:
Well, that is our simple Country List. Many information should be added to each country I think. But in this example, I only add Capital, Currency, Continent and Language.
Please tell me if I had made a mistake in the code above. I'm still learning
Screenshot:
Showthread:
[attachment=315]
Threadlist:
[attachment=316]
Live Demo:
http://www.14.mynie.co.cc/forumdisplay.php?fid=47
We will try to create a simple country list with XThreads. Maybe we can use this just for a country database/list, or discussion based on user's country.
Yeah, I know that maybe this is useless. But I just want to share it
Here is a simple way to do that:
- Forum settings:
- Default Sort By: Thread subject
- Default Sort Order: Ascending
- Template Prefix: xtcl_
- Thread Grouping: 3
- Show first post on every showthread page: Yes
- Enable XThreads' Inline Forum Search: Yes
- Override Threads Per Page: 21
- Hide Forum: Yes
We need to put this forum URL manually in our template (eg: header template). - Don't include this forum's threads/posts in global forum statistics: Yes
- Custom WOL Text:
- Forum Display:
Code:
Browsing <a href="{1}">{2}</a>
- New Thread: Adding a country to Country List
- New Reply:
Code:
Discussion in <a href="{1}">{2}</a> country
- Show Thread:
Code:
Viewing <a href="{1}">{2}</a> country
- Forum Display:
- Custom Thread Fields Setting:
- Textbox for Capital:
- Title: Capital
- Key: xtlc_cap
- Applicable Forums: 'select our Country List forum'
- Editable by / Required Field?: Everyone (required)
- Display Format:
HTML Code<tr> <td class="trow1" width="99"><strong>Capital</strong></td> <td class="trow1" width="1"><strong>:</strong></td> <td class="trow1">{VALUE}</td> </tr>
- Textbox for Language:
- Title: Language
- Key: xtlc_lang
- Applicable Forums: 'select our Country List forum'
- Editable by / Required Field?: Everyone (required)
- Display Order: 2
- Display Format:
HTML Code<tr> <td class="trow1" width="99"><strong>Language</strong></td> <td class="trow1" width="1"><strong>:</strong></td> <td class="trow1">{VALUE}</td> </tr>
- Textbox for Currency:
- Title: Currency
- Key: xtlc_cur
- Applicable Forums: 'select our Country List forum'
- Editable by / Required Field?: Everyone (required)
- Display Order: 3
- Display Format:
HTML Code<tr> <td class="trow1" width="99"><strong>Currency</strong></td> <td class="trow1" width="1"><strong>:</strong></td> <td class="trow1">{VALUE}</td> </tr>
- Listbox for Continent:
- Title: Continent
- Key: xtlc_con
- Applicable Forums: 'select our Country List forum'
- Input Field Type: Listbox
- Field Input Height: 1
- Values List:
Code:Asia Africa Europe North America Oceania South America
- Editable by / Required Field?: Everyone (required)
- Allow Filtering: Yes
- Display Order: 4
- Display Format:
HTML Code<tr> <td class="trow1" width="99"><strong>Continent</strong></td> <td class="trow1" width="1"><strong>:</strong></td> <td class="trow1">{VALUE}</td> </tr>
- File input field type for Country Flag image:
- Title: Country Flag
- Key: xtlc_flag
- Applicable Forums: 'select our Country List forum'
- Input Field Type: File
- Valid File Extensions: jpg|jpeg|gif|png
Modify it as our needs. It is the extensions of image ext can be uploaded. - Maximum File Size: 1048576
Modify it as our needs. It is a maximum file size (in bytes) that can be uploaded. - Editable by / Required Field?: Everyone (required)
- Allow Filtering: Yes
- Display Order: 5
- Only Accept Image Files: Yes
- Image Thumbnail Generation: 120x90|240x180
- Display Format:
HTML Code<if THIS_SCRIPT == 'forumdisplay.php' then> <img src="{URL}/thumb120x90" alt="{$thread['subject']}" title="{$thread['subject']}" /> <else> <a href="{URL}" target="_blank"><img src="{URL}/thumb240x180" alt="{$thread['subject']}" title="{$thread['subject']}" /></a> </if>
- Textbox for Capital:
- New templates in Global Template.
Admin CP -> Templates & Style -> Templates -> Global Templates:
- xtcl_forumdisplay_group_sep
HTML Code</tr><tr>
- xtcl_forumdisplay_nothreads
HTML Code<td> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead"> <strong>No Country</strong> </td> </tr> <tr> <td align="center" class="trow1"> {$lang->nothreads} </td> </tr> </table> </td>
- xtcl_forumdisplay_searchforum_inline
HTML Code<div class="largetext" style="text-align: center;"> <form action="forumdisplay.php" method="get"> Search Country <input type="text" class="textbox" name="search" size="35" value="{$searchval}" /> {$gobutton} <input type="hidden" name="fid" value="{$fid}" /> <input type="hidden" name="sortby" value="{$sortby}" /> <input type="hidden" name="order" value="{$sortordernow}" /> <input type="hidden" name="datecut" value="{$datecut}" /> </form> </div>
- xtcl_forumdisplay_sticky_sep
HTML Code<td colspan="{$colspan}" style="display: none;"></td> </tr> <tr>
Well, we need the <td> part to pass validator.
- xtcl_forumdisplay_thread
HTML Code<td width="33%" valign="top"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" width="100%"> <div style="text-align: center;"> <strong><a href="{$thread['threadlink']}" class="{$inline_edit_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a></strong> </div> </td> {$modbit} </tr> <tr> <td class="trow1" align="center" valign="middle" colspan="{$colspan}"> <div> <a href="{$thread['threadlink']}">{$GLOBALS['threadfields']['xtlc_flag']['value']}</a> </div> </td> </tr> </table> </td>
- xtcl_forumdisplay_threadlist
HTML Code<table border="0" width="100%" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}"> <tr> <td valign="top"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead largetext"> <div style="text-align: center;"><a href="{$forumurl}"><strong>Continent</strong></a></div> </td> {$inlinemodcol} </tr> <tr> <td class="trow1" colspan="2"> <table width="100%" border="0"> <tr> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=Asia"><strong>Asia</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=Asia"><img src="images/asia.jpg" alt="" title="View Countries From Asia Continent" /></a> </td> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=Africa"><strong>Africa</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=Africa"><img src="images/africa.jpg" alt="" title="View Countries From Africa Continent" /></a> </td> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=Europe"><strong>Europe</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=Europe"><img src="images/europe.jpg" alt="" title="View Countries From Europe Continent" /></a> </td> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=North America"><strong>North America</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=North America"><img src="images/north_america.jpg" alt="" title="View Countries From North America Continent" /></a> </td> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=Oceania"><strong>Oceania</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=Oceania"><img src="images/oceania.jpg" alt="" title="View Countries From Oceania Continent" /></a> </td> <td class="trow1" style="text-align: center;"> <a href="{$forumurl_q}filtertf_xtlc_con=South America"><strong>South America</strong></a><br /> <a href="{$forumurl_q}filtertf_xtlc_con=South America"><img src="images/south_america.jpg" alt="" title="View Countries From South America Continent" /></a> </td> </tr> </table> {$searchforum} </td> </tr> </table> <br /> </td> </tr> <tr> <td valign="top"> <table border="0" width="100%"> <tr> {$threads}{$nullthreads} </tr> </table> <div class="float_left"> {$multipage} </div> <div class="float_right"> {$newthread} </div> </td> </tr> </table> <br style="clear: both;" /> <br /> <div class="float_right" style="text-align: right;"> {$inlinemod} </div> <br style="clear: both" /> <div class="smalltext" align="center"> {$foruminfo['name']}<br />Powered By <a href="http://mybbhacks.zingaburga.com">XThreads</a> - <a href="http://mybbhacks.zingaburga.com">MyBB Hacks</a> </div> {$inline_edit_js}
We put all continent filtering URL in this template. There is a img tag in each the continent filter. Modify the images URL and type as our needs.
- xtcl_forumdisplay_threads_sep
HTML Code<td colspan="{$colspan}" style="display: none;"></td> </tr> <tr>
Again, we need the <td> part to pass the validator, if there is a global announcement and there is no sticky thread in this forum.
- xtcl_forumdisplay_thread_null
HTML Code<td width="33%" valign="top"></td>
- xtcl_postbit_first and xtcl_postbit_first_classic
HTML Code{$ignore_bit} <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" width="100%" style="{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}"> <tr> <td width="300" valign="top"> <table border="0" cellspacing="0" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" valign="top" style="text-align: center;"> <a name="pid{$post['pid']}" id="pid{$post['pid']}"></a> <div class="largetext">{$post['subject']}</div> </td> </tr> <tr> <td class="trow1" valign="top" style="text-align: center;"> <div>{$GLOBALS['threadfields']['xtlc_flag']['value']}</div> </td> </tr> </table> <br /> <table border="0" cellspacing="0" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" colspan="3" align="center"> <div class="largetext">Short Info</div> </td> </tr> {$GLOBALS['threadfields']['xtlc_cap']} {$GLOBALS['threadfields']['xtlc_cur']} {$GLOBALS['threadfields']['xtlc_con']} {$GLOBALS['threadfields']['xtlc_lang']} </table> </td> <td valign="top"> <table border="0" cellspacing="0" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" colspan="3"> {$post['posturl']} <span class="largetext"> <strong>Additional Info About {$post['subject']}</strong> </span> </td> </tr> <tr> <td class="trow1" valign="top" colspan="3"> <div id="pid_{$post['pid']}" style="padding: 5px 0 5px 0;"> {$post['message']} </div> <div id="edited_by_{$post['pid']}">{$post['editedmsg']}</div> </td> </tr> <tr valign="bottom"> <td align="right" class="tcat" colspan="3"> {$post['button_edit']} {$post['button_quickdelete']} {$post['button_quote']} {$post['button_multiquote']} {$post['button_report']} {$post['button_warn']} </td> </tr> </table> </td> </tr> </table>
- xtlyrics_forumdisplay_sticky_sep
HTML Code<div><strong>Featured Songs</strong></div>
- xtcl_showthread
HTML Code<html> <head> <title>{$thread['subject']}</title> {$headerinclude} <script type="text/javascript"> <!-- var quickdelete_confirm = "{$lang->quickdelete_confirm}"; // --> </script> <script type="text/javascript" src="jscripts/thread.js?ver=1400"></script> </head> <body> {$header} {$first_post} <br /> <div align="center"> <strong>« <a href="{$next_oldest_link}">{$lang->next_oldest}</a> | <a href="{$next_newest_link}">{$lang->next_newest}</a> »</strong> </div> <br /> <table border="0" cellspacing="0" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead largetext"> <div style="text-align: center;"> <strong>Discussions Of Users From {$thread['subject']}</strong> </div> </td> </tr> <tr> <td class="trow1"> <div id="posts"> {$posts} </div> </td> </tr> <tr> <td class="tfoot"> {$search_thread} </td> </tr> </table> <br class="clear" /> <div class="float_left"> {$multipage} </div> <div style="padding-top: 4px;" class="float_right"> {$newreply} </div> <br style="clear: both;" /> {$quickreply} <br /> <div class="smalltext" align="center"> {$forum['name']}<br />Powered By <a href="http://mybbhacks.zingaburga.com">XThreads</a> - <a href="http://mybbhacks.zingaburga.com">MyBB Hacks</a> </div> <br class="clear" /> <div class="float_right" style="text-align: right;"> {$moderationoptions} </div> <br style="clear: both;" /> {$footer} </body> </html>
- xtcl_showthread_noreplies
HTML Code<div id="xthreads_noreplies" style="text-align: center;"> There is no discussions in this country </div>
- xtcl_forumdisplay_group_sep
Well, that is our simple Country List. Many information should be added to each country I think. But in this example, I only add Capital, Currency, Continent and Language.
Please tell me if I had made a mistake in the code above. I'm still learning
Screenshot:
Showthread:
[attachment=315]
Threadlist:
[attachment=316]
Live Demo:
http://www.14.mynie.co.cc/forumdisplay.php?fid=47