Author Topic: How To Create Front Page Like Nairaland  (Read 640 times)

0 Members and 1 Guest are viewing this topic.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
How To Create Front Page Like Nairaland
« on: May 19, 2017, 03:16:37 PM »
hello please.. i don't know if anyone know how i can create a front page like nairaland.


Nobody is Useless

All Student Forum

How To Create Front Page Like Nairaland
« on: May 19, 2017, 03:16:37 PM »

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #1 on: May 20, 2017, 09:02:10 PM »
You will need a board news script that is compatible with the portal you are using. You can request this from any of the portal site, like simple portal if you are using their portal. I use to have one before but i cant locate the script again, but i will check and update this post.
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #2 on: May 22, 2017, 12:17:27 PM »
Thanks so much sir
Nobody is Useless

All Student Forum

Re: How To Create Front Page Like Nairaland
« Reply #2 on: May 22, 2017, 12:17:27 PM »

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #3 on: May 23, 2017, 11:39:53 AM »
I have not been able to get hold of the code, but i can see you have already added the code on your website to give you the Nairaland Front Page. Can you share the code in here?
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #4 on: May 29, 2017, 06:39:12 AM »
no.... i didn't get the board news from Simple Portal..... and those ones on the front page, i added a new HTML Block below the head Block inside simple Portal.......then i copied and pasted the Topic and inserted the link to the topic using wordpress.com. So i have to keep copying and pasting and inserting the link, make it bold,... every time i want to get a topic to the front page. That's not easy and too tasking. I need a easy one like a MOD that would just move.
Nobody is Useless

All Student Forum

Re: How To Create Front Page Like Nairaland
« Reply #4 on: May 29, 2017, 06:39:12 AM »

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #5 on: May 29, 2017, 12:12:27 PM »
You can use this custom code, just copy it into the simple portal php block and save

Code: [Select]
global $context;

// Adjust your specific parameters
// when/if using the pagination for other blocks on the same page, remember to increment the formId
$parameters['boards'] = 1;
$parameters['limit'] = 50;
$parameters['perPage'] = 5;
$parameters['display'] = 'full';
$parameters['bodyStyle'] = 'windowbg';
$parameters['formId'] = 1;

// Do not bother altering the rest of the code...
$context['current_page' . $parameters['formId']] = !empty($context['current_page' . $parameters['formId']]) ? (int)$context['current_page' . $parameters['formId']] : 1;
$context['current_page' . $parameters['formId']] = (!empty($_REQUEST['current_page' . $parameters['formId']]) ? (int)$_REQUEST['current_page' . $parameters['formId']]-1 : $context['current_page' . $parameters['formId']] - 1);
customRecent($parameters);

function custom_pagination($content, $count=20, $id=1)
{
/* PHP pagination - max 7 visible integers and 6 periods (all links) - current page encircled with square brackets
* This php pagination code was developed by Underdog copyright 2013
* [url]http://webdevelop.comli.com[/url]
* Licensed under the GNU Public License: [url]http://www.gnu.org/licenses/gpl.html[/url]
*/

// This particular function is only used when opting an entire table else it is not necessary
global $context;

/*  Set the $context variables for the display template  */
$context['current_count' . $id] = count($content);
$context['current_pages' . $id] = (($context['current_count' . $id]) / $count)   1;

if (count($content) <= $count || $count < 2)
{
$context['current_pages' . $id] = 0;
return $content;
}

if (($context['current_count' . $id] / $count) == (int)($context['current_count' . $id] / $count))
$context['current_pages' . $id] = ($context['current_count' . $id] / $count);

$context['current_showResults' . $id] = array(((int)$context['current_page' . $id] * $count), (((int)$context['current_page' . $id]   1) * $count) - 1);
       



if ((int)$context['current_page' . $id] 1 == (int)$context['current_pages' . $id])
    $context['current_showResults' . $id][1] = count($content);
else
    $context['current_showResults' . $id][1] = (int)$context['current_page' . $id]*$count   ($count-1);
   
foreach($content as $key => $var)
{
if ((int)$key >= (int)$context['current_showResults' . $id][0] && (int)$key <= (int)$context['current_showResults' . $id][1])
$new_content[] = $var;
}

if (!empty($new_content))
$context['current_showResults' . $id][1] = ((int)$context['current_page' . $id]*$count)   count($new_content);
else
$new_content = $content;

return $new_content;
}

function custom_pages($lang, $anchor, $link, $pages, $sort=false, $order=false, $id=1, $style='windowbg')
{
/* PHP pagination - max 7 visible integers and 6 periods (all links) - current page encircled with square brackets
* This php pagination code was developed by Underdog copyright 2013
* [url]http://webdevelop.comli.com[/url]
* Licensed under the GNU Public License: [url]http://www.gnu.org/licenses/gpl.html[/url]
*/
global $context, $txt, $scripturl;

$name = 'custom_SpForm' . $id;
$pageCount = 1;
$display = array('page' => false, 'pages' => '0');
$page = !empty($context['current_page' . $id]) ? (int)$context['current_page' . $id] : 0;
$display['pages'] = !empty($pages) ? (int)$pages : 1;

if ($display['pages'] > 1)
{
$display['page'] =  '
<script type="text/javascript"><!-- // --><![CDATA[
function changeColor(s, formId)
{
for (var i=1; i<=3; i  )
                document.getElementById("link" i formId).style.color = i==s ? "red" : "blue";
}
function changeColorBack(s, formId)
{
for (var i=1; i<=3; i  )
document.getElementById("link" i formId).style.color = i==s ? "blue" : "blue";
}
// ]]></script>
<form name="' . $name .'" action="'.$link.'" method="post" id="' . $name .'">
<span style="text-align:center;position:relative;width:99%;display:inline-block;">
' . $lang . '<br />';

while ($pageCount < (int)$display['pages'] 1)
{
$current_page = (int)$page 1;
$total = (int)$display['pages'];
       
if ($pageCount == 1 || $pageCount == $total || $pageCount == $current_page || $pageCount == $current_page 1 ||
    $pageCount == $current_page 2 || $pageCount == $current_page-1 || $pageCount == $current_page-2)
{
                if ((int)$pageCount == (int)$page 1)
$display['page'] .= '
[<input class="' . $style . '" type="button" onclick="this.href=\'javascript: void(0)\';" onmouseout="changeColorBack('. $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="' . $pageCount . '" />] ';
        else
$display['page'] .= '
<input class="' . $style . '" type="submit" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="' . $pageCount . '"  /> ';
}
elseif ($pageCount < $current_page-2 && $pageCount > $current_page-6)
$display['page'] .= '
<input class="' . $style . '" type="submit" onchange="document.getElementById(\'link' . $pageCount . $id . '\').value='.$pagecount.'" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="." onclick="sp_submitPage();" /> ';
elseif ($pageCount > $current_page 2 && $pageCount < $current_page 6)
$display['page'] .= '
<input class="' . $style . '" type="submit" onchange="document.getElementById(\'link' . $pageCount . $id . '\').value='.$pagecount.'" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="." onclick="sp_submitPage();" /> ';

$pageCount  ;
}

$display['page'] .= '
</span>   
</form>';
}

return $display;
}

/* Current url */
function currentCustomPage($pageURL = 'http://')
{
if (!empty($_SERVER["HTTPS"]))
$pageURL = "https://";   
   
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

return $pageURL;
}

function customRecent($parameters)
{
global $txt, $scripturl, $settings, $context, $color_profile;

$boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
$limit = !empty($parameters['limit']) ? (int)$parameters['limit'] : 15;
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
$display = empty($parameters['display']) ? 'compact' : 'full';
$style = !empty($parameters['bodyStyle']) ? $parameters['bodyStyle'] : 'windowbg';
$id = !empty($parameters['formId']) ? (int)$parameters['formId'] : 1;
$perPage = !empty($parameters['perPage']) ? (int)$parameters['perPage'] : 10;

// $recent_items = $type($limit, null, $boards, 'array');
       
        $items = custom_pagination($type($limit, null, $boards, 'array'), $perPage, $id);       
       
        $context['custom_display' . $id] = array('page' => false, 'pages' => '0');
$context['custom_display' . $id] = custom_pages($txt['pages'], false, currentCustomPage(), $context['current_pages' . $id], false, false, $id, $style);
       
if (empty($items))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
else
$items[count($items) - 1]['is_last'] = true;

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['poster']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}

if ($display == 'compact')
{
foreach ($items as $key => $item)
echo '
<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
}
elseif ($display == 'full')
{
echo '
<table class="sp_fullwidth">';

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
', sp_embed_image(empty($parameters['type']) ? 'post' : 'topic'), '
</td>
<td class="sp_recent_subject">
<a href="', $item['href'], '">', $item['subject'], '</a>
', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
</td>
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
</tr>';

echo '
</table>';
}
       
        echo $context['custom_display' . $id]['page'];   
}

Note:- You can adjust the boards you want to output the topics from by adjusting the section of the code
Code: [Select]
$parameters['boards'] = 1; adjust it like this
Code: [Select]
$parameters['boards'] = 1, 2, 3, 4, 5;
OR

You can use this code as well, this will output something like this also

Name of block

Link to topic 1
Link to topic 2
Link to topic 3

Code: [Select]
global $smcFunc, $scripturl, $modSettings;

$id_board = 1;

$request = $smcFunc['db_query']('', '
SELECT t.id_topic, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_board = {int:board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:approved}
AND m.approved = {int:approved}' : '') . '
ORDER BY m.subject',
array(
'board' => $id_board,
'approved' => 1,
)
);
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$topics[$row['id_topic']] = $row['subject'];
$smcFunc['db_free_result']($request);

echo '
<ul>';

if (empty($topics))
{
echo '
<li>There aren\'t any topics.</li>';
}
else
{
foreach ($topics as $id => $subject)
echo '
<li><a href="', $scripturl, '?topic=', $id, '.0">', $subject, '</a></li>';
}

echo '
</ul>';

- Change $id_board as the id of the board you want to fetch topics from.

- If you want to limit the topics:
find this code
Code: [Select]
ORDER BY m.subject',Replace with
Code: [Select]
ORDER BY m.subject
LIMIT {int:limit}',
Find code
Code: [Select]
'approved' => 1,Replace with
Code: [Select]
'approved' => 1,
'limit' => 10,
- If you want to change the sort order to the newest first:
Find this code
Code: [Select]
ORDER BY m.subjectReplace with
Code: [Select]
ORDER BY t.id_topic DESC
OR

Also you can use the simpleportal block called Recent Posts/Topics. it will give you almost the same feel.
You can locate this in the simpleportal admin panel, click on Add Block and select Recent Posts/Topics
« Last Edit: May 29, 2017, 12:56:03 PM by mfoniso »
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #6 on: May 29, 2017, 06:28:16 PM »
Thank you so much. Let me try it and then get back
Nobody is Useless

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #7 on: May 29, 2017, 08:31:23 PM »
Quote
You can use this custom code, just copy it into the simple portal php block and save

You meant through Admin>> Simple Portal>> add Block>> Custom PHP.....

or its through somewhere else? ...

I don't really understand all of those up there. I tried the first code, i got error. I appreciate your efforts trying to help. Maybe you can make it more simpler sir.... am a beginner and please use English language
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #8 on: May 29, 2017, 09:27:25 PM »
Quote
You meant through Admin>> Simple Portal>> add Block>> Custom PHP
Yes, thats what i meant
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #9 on: May 30, 2017, 06:36:11 AM »
sir i got error......
Nobody is Useless

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #10 on: May 30, 2017, 06:40:48 AM »
this was the error i got "Database error in block code. Please check the code."
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #11 on: May 30, 2017, 09:10:53 AM »
Which of the code did you use?
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #12 on: May 30, 2017, 10:18:29 AM »
the first one. The second one worked but its not really the type i want......
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #13 on: May 30, 2017, 07:38:17 PM »
ok, am glad one of it is working, you remember i said it was an old code i used before, with smf constant update and changes its hard to maintain any code.
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #14 on: May 31, 2017, 04:35:20 PM »
thanks
Nobody is Useless

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #15 on: June 21, 2017, 05:32:14 AM »
can i set the particular numbers of topics i want to display
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #16 on: June 21, 2017, 06:05:34 PM »
- If you want to limit the topics:
find this code

Code: [Select]
ORDER BY m.subject',
Replace with

Code: [Select]
ORDER BY m.subject
LIMIT {int:limit}',

Find code
Code: [Select]
'approved' => 1,
Replace with

Code: [Select]
'approved' => 1,
'limit' => 10,
Change 10 to the number you want, lets say 50
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #17 on: June 22, 2017, 03:15:50 AM »
Quote
'approved' => 1,
      'limit' => 10,

this does not work..... it does not limit the numbers
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #18 on: June 22, 2017, 03:34:13 AM »
Did you change the value 10 to what you wanted and it did not work?
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #19 on: June 22, 2017, 02:10:33 PM »
Yes exactly.....it did not work
Nobody is Useless

Offline mfoniso

  • Administrator
  • Hero Member
  • *****
  • Posts: 2154
  • Country: ng
  • Karma: +0/-0
  • Gender: Male
    • Play Lsit Hub
Re: How To Create Front Page Like Nairaland
« Reply #20 on: June 22, 2017, 09:42:47 PM »
Ok, i cant figure out why its not working
Please do not PM me questions, ask all your questions in the forum, for others to learn from.

Offline lola

  • Full Member
  • ***
  • Posts: 108
  • Country: ng
  • Karma: +1/-0
  • Gender: Female
Re: How To Create Front Page Like Nairaland
« Reply #21 on: June 28, 2017, 11:11:51 AM »
its working now..... but its a little bit squeezed with each others.... i want to ask maybe there is a way i can give a little space.... or at least make the topics bold....
Nobody is Useless

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
10 minus 10 = ?:
What letter is missing in this word 'Gogle':

Related Topics

  Subject / Started by Replies Last post
13 Replies
4488 Views
Last post November 18, 2016, 05:12:48 PM
by mfoniso
0 Replies
356 Views
Last post October 10, 2013, 09:27:52 AM
by lawreno3
0 Replies
1914 Views
Last post October 14, 2013, 12:24:12 PM
by mfoniso
3 Replies
1174 Views
Last post June 28, 2014, 10:26:23 PM
by mfoniso
4 Replies
173 Views
Last post April 14, 2017, 10:01:08 AM
by mfoniso