Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Country List
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Country List
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 Biggrin

Here is a simple way to do that:

  1. 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

  2. Custom Thread Fields Setting:

    1. 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>

    2. 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>

    3. 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>

    4. 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:
        1
        2
        3
        4
        5
        6
        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>

    5. 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>


  3. New templates in Global Template.
    Admin CP -> Templates & Style -> Templates -> Global Templates:
    1. xtcl_forumdisplay_group_sep

      HTML Code
      </tr><tr>

    2. xtcl_forumdisplay_nothreads

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      <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>

    3. xtcl_forumdisplay_searchforum_inline

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      <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>

    4. xtcl_forumdisplay_sticky_sep

      HTML Code
      <td colspan="{$colspan}" style="display: none;"></td>
      </tr>
      <tr>

      Well, we need the <td> part to pass validator.

    5. xtcl_forumdisplay_thread

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      <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>

    6. xtcl_forumdisplay_threadlist

      HTML Code
      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
      66
      67
      68
      69
      70
      71
      72
      73
      <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.

    7. 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.

    8. xtcl_forumdisplay_thread_null

      HTML Code
      <td width="33%" valign="top"></td>

    9. xtcl_postbit_first and xtcl_postbit_first_classic

      HTML Code
      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
      {$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>

    10. xtlyrics_forumdisplay_sticky_sep

      HTML Code
      <div><strong>Featured Songs</strong></div>

    11. xtcl_showthread

      HTML Code
      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
      <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>&laquo; <a href="{$next_oldest_link}">{$lang->next_oldest}</a> | <a href="{$next_newest_link}">{$lang->next_newest}</a> &raquo;</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>

    12. xtcl_showthread_noreplies

      HTML Code
      <div id="xthreads_noreplies" style="text-align: center;">
      There is no discussions in this country
      </div>



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 Biggrin

Screenshot:

Showthread:
   

Threadlist:
   

Live Demo:
http://www.14.mynie.co.cc/forumdisplay.php?fid=47

(This post was last modified: 02-13-2011 03:21 AM by RateU.)
12-16-2010 12:53 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Country List
Actually, quite a good base for something like a CMS.
Looks good there Smile

My Blog
12-16-2010 12:58 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #3
RE: Country List
Thanks, Yumi Biggrin

12-16-2010 01:15 PM
Find all posts by this user Quote this message in a reply
TriTop Offline
Member
***
Posts: 53
Joined: Apr 2008
Post: #4
RE: Country List
Well, this fairly beats me! Once again a really brilliant idea. Carry on the good work and we dont need an extern CMS anymore. 50star.GIF
12-17-2010 05:20 AM
Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #5
RE: Country List
Very nice Smile

[Image: logo.png]

[Image: twitter.png]
12-17-2010 07:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Sector Offline
Junior Member
**
Posts: 6
Joined: May 2012
Post: #6
RE: Country List
Allow me to bring back this topic!

(12-16-2010 12:53 PM)RateU Wrote:  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.

This is an interesting idea! Say, how can we link a user's country displayed in the postbit custom user fields...

Imagine you have:

Age : 25
Gender : M
Country : Panama

How would we HREF "Panama" to Panama's discussion thread?

Cool

Maybe creating a new SQL table and associating a unique country ID to a forum ID?

Bah... can't figure anything Arf
11-15-2012 02:25 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: Country List
(11-15-2012 02:25 PM)Sector Wrote:  Maybe creating a new SQL table and associating a unique country ID to a forum ID?
In this example, the "country id" is the thread id.

(11-15-2012 02:25 PM)Sector Wrote:  how can we link a user's country displayed in the postbit custom user fields...

Imagine you have:

Age : 25
Gender : M
Country : Panama

How would we HREF "Panama" to Panama's discussion thread?
I think there are some ways to do that.
You can use Template Conditional for creating an array, then work using the array.
Or, you can create your own plugin to redirect the user based on an input value when they click the profile fields link in postbit and/or profile.

11-16-2012 04:33 AM
Find all posts by this user Quote this message in a reply
Anil Gidwani Offline
Junior Member
**
Posts: 3
Joined: Jul 2013
Post: #8
RE: Country List
Great and simple example for a newbie!  Thanks.

One (dumb) question:  How does one decide which of the templates need to be changed (I assume that's what Custom WOL text stands for).

Do I really need to know the MyBB template system inside out and understand the entire logic of the templates, css files and php code before I can come up with my own CMS?

Is there a good tutorial on building custom templates for myBB starting with a top-down design of the system?
I'm unable to see the online demo!

I guess what I'm looking for mainly is the following:

a) How to determine which of the original myBB templates will need to change?
b) Which new ones will be required?
c) Which myBB variables can be reused?
d) Which new variables typically need to be defined? Where are these set?

and so on.  A practical primer, if you will, of the process, in addition to the detailed code listings in this thread, of course.
(This post was last modified: 07-22-2013 02:42 AM by Anil Gidwani.)
07-22-2013 02:37 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Country List
(07-22-2013 02:37 AM)Anil Gidwani Wrote:  One (dumb) question:  How does one decide which of the templates need to be changed (I assume that's what Custom WOL text stands for).
WOL = who's online, the stuff you see in the /online.php page, unrelated to templates.

(07-22-2013 02:37 AM)Anil Gidwani Wrote:  Do I really need to know the MyBB template system inside out and understand the entire logic of the templates, css files and php code before I can come up with my own CMS?
You should know HTML/CSS and the MyBB template system before attempting to use XThreads.  PHP/Javascript knowledge is not required, but helpful.

(07-22-2013 02:37 AM)Anil Gidwani Wrote:  a) How to determine which of the original myBB templates will need to change?
b) Which new ones will be required?
The template names are listed in the tutorial, if the template doesn't already exist in MyBB, then it's new.
As a guide though, you'll notice most of the names are prefixed.  This means it's a new template, although it's based off a stock MyBB template.

(07-22-2013 02:37 AM)Anil Gidwani Wrote:  c) Which myBB variables can be reused?
There isn't a predefined set (see how the MyBB template system works).

(07-22-2013 02:37 AM)Anil Gidwani Wrote:  d) Which new variables typically need to be defined? Where are these set?
You cannot define new variables in templates, normally at least.

My Blog
07-22-2013 09:54 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: