collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 344
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: How to edit a Block of type Articles  (Read 9695 times)

0 Members and 1 Guest are viewing this topic.

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
How to edit a Block of type Articles
« on: October 20, 2015, 12:30:50 PM »
My question is more generally applicable to any stock block. I am using topics from a "Blog" board to feed an "Articles" type block with the latest 5 entries (I call this block "Recent Blogs"), but I would like to customize the latter further by adding a column for time and date. Is it possible to edit this block within the portal settings? Or would I have to dig into the file directly (which file would that be)? Or could I just copy the code from this file and then create a custom php block that I can then edit from within the settings? Has anyone done this or similar in a simple way?

An easier task yet would be to add a link at the bottom of the "Recent blogs" block that takes the member to the "Blog" board in the forum area, where naturally all blogs ever are listed - but otherwise the same questions as above apply.

Regards to all.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #1 on: October 20, 2015, 07:15:14 PM »
Hello,

All the blocks are stored in /Sources/PortalBlocks.php, each with its own function.

You can modify the block in that file, or you can create a custom PHP block and do the same like you said, however you will need to make some adjustments as parameters don't need to be passed.

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #2 on: October 21, 2015, 11:52:41 AM »
Thanks. I looked in the file, found the function, got lost in the code :), tried what little I thought might work (it didn't), so it's time to hit the books before I can move on. If and when I get this done, will post here again.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #3 on: October 21, 2015, 01:08:02 PM »
What did you try and do? I could help you with the edits.

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #4 on: October 21, 2015, 06:06:41 PM »
I appreciate your offer and I will make use of it when I feel more prepared. Right now I am not up to speed but working on it.

So far I tried to identify the functions, the calls, the parameters and am looking into their relationship with the db. For a quick try, i wanted to add somewhere a line that puts "hello" at the bottom of my box, after the liat of items already there (failed to achieve that but threw no error either.

For easier practice going forward I want to install a copy of the forum in WAMP so I can try things while offline. I will surely be back soon.

Thanks again.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #5 on: October 21, 2015, 11:10:07 PM »
So far so good: I mirrored my forum offline and found out that what I wanted to do was actually easier than seemed: I simply inserted a link at the bottom of the list. Remains to work out the styling and this little project is all done!

Regards.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #6 on: October 21, 2015, 11:13:36 PM »
Could you post the edits you made? To help anyone else wanting to achieve the sme

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #7 on: October 21, 2015, 11:21:13 PM »
At the moment Im working on the localhost and posting here from my mobile, but yes, I will.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #8 on: October 22, 2015, 06:56:54 PM »
I edited PortalBlocks.php and at almost the bottom of the function (line 2525 in my case) I added this:

Code: [Select]
// at bottom of blogs/article block add link to all topics
echo ' <hr>';
echo ' <table class="sp_fullwidth sp_articles">';
echo ' <tr>
<td class="sp_articles sp_center">';
echo ' <a href="http://localhost/myforum/index.php?board=28.0">',"see all blog entries",'</a>';
echo '
</td>
</tr>

I agree that it may not be the best way, and that it can be styled even further, but it works for me right now and allows me to quickly move on.

Should you be inclined to help, here's what I am thinking about: (1) what if I modify my boards and what's now board=28.0 changes, is there a way to write my code so I don't have to remember to come back here and hardcode it with the new value? and (2) instead of hardcoding the path/url, I'd rather use some already defined variable.

Hope this helps.

Regards.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #9 on: October 22, 2015, 11:45:46 PM »
Here, you could try doing this and tell me the result.

Open /Sources/PortalBlocks.php

Find:
Code: [Select]
$request = $smcFunc['db_query']('','
SELECT
m.id_topic, m.subject, m.poster_name, c.picture, c.name,
mem.id_member, mem.real_name, mem.avatar,
at.id_attach, at.attachment_type, at.filename

Replace with:
Code: [Select]
$request = $smcFunc['db_query']('','
SELECT
m.id_topic, m.subject, m.poster_name, m.id_board, c.picture, c.name,
mem.id_member, mem.real_name, mem.avatar,
at.id_attach, at.attachment_type, at.filename

Find:
Code: [Select]
$articles[] = array(
'id' => $row['id_topic'],

Replace with:
Code: [Select]
$articles[] = array(
'id' => $row['id_topic'],
'id_board' => $row['id_board'],

Find:
Code: [Select]
<td>
<span class="sp_articles_title">', $article['poster']['link'], '</span><br />
', $article['link'], '
</td>
</tr>';

Replace with:
Code: [Select]
<td>
<span class="sp_articles_title">', $article['poster']['link'], '</span><br />
', $article['link'], '
</td>
</tr>
<tr>
<td rowspan="2" align="center">
<span><a href="' . $scripturl . '?board=' . $article['id_board'] . '.0">View all entries...</a></span>
</td>
</tr>';

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #10 on: October 23, 2015, 09:38:24 AM »
I commented out my edits and plugged in your code, and without seeing any errors, the link does not show up in the block... :( I see though what you're doing and right now I'm trying to understand why it doesn't work.

Thanks for your support!
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #11 on: October 23, 2015, 04:24:42 PM »
Hm... It turns out that if I move the link-building code outside of the table structure it's in right now (and create a table structure for it just above the end of the function), the code works at least to the point that a link shows up in the block. I keep studying it...
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #12 on: October 24, 2015, 09:44:14 PM »
You could do this instead:

Find:
Code: [Select]
<td>
<span class="sp_articles_title">', $article['poster']['link'], '</span><br />
', $article['link'], '
</td>
</tr>';

Replace with:
Code: [Select]
<td>
<span class="sp_articles_title">', $article['poster']['link'], '</span><br />
', $article['link'], ' <div style="align: right;"><a href="' . $scripturl . '?board=' . $article['id_board'] . '.0">View all entries...</a></div>
</td>
</td>
</tr>';

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #13 on: October 27, 2015, 09:34:24 AM »
I tried the code and again, the link does not show up in the block. So again I moved it outside the loop/table to just above the end of the function, like this:

Find:
Code: [Select]
}
}
function sp_shoutbox($parameters, $id, $return_parameters = false)

Replace with:
Code: [Select]
}
    echo '  <hr /> <div style="text-align:center"><a href="' . $scripturl . '?board=' . $article['id_board'] . '.0">View all entries...</a></div> ';
}
function sp_shoutbox($parameters, $id, $return_parameters = false)

In building the link I gave up on the <table> structure (overkill) and <span> in favor of the <div> which acts as a block and takes all the width available to it.

Thanks again for your help; I believe I got all that I asked for.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #14 on: October 28, 2015, 12:25:42 AM »
I believe I managed to figure out why the link would not show the way you coded it for me: it has to do with the value of $image. Mine is empty (why is that so? Could it be because I use no avatar?). So at this point in the code

Code: [Select]
if (empty($image))
{
...
foreach
...
}
else
{
...
foreach
...
}

the first (top) foreach routine is executed, not the second (bottom) one.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #15 on: October 28, 2015, 12:48:39 AM »
$image is only set if you are using a category image.

If it's empty, you can edit it like so;

Find:
Code: [Select]
foreach ($articles as $article)
echo '
<li>', sp_embed_image('topic'), ' ', $article['link'], ' </li>';

Replace with:
Code: [Select]
foreach ($articles as $article)
echo '
<li>', sp_embed_image('topic'), ' ', $article['link'], ' <a href="' . $scripturl . '?board=' . $article['id_board'] . '.0">View all entries...</a></li>';

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #16 on: October 28, 2015, 01:00:13 AM »
For something a bit more aesthetically pleasing, you could do this instead:

Code: [Select]
foreach ($articles as $article)
echo '
<li>', sp_embed_image('topic'), ' ', $article['link'], ' <span class="smalltext"><a href="' . $scripturl . '?board=' . $article['id_board'] . '.0">(view more)</a></span></li>';

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #17 on: October 28, 2015, 01:09:15 AM »
Thanks, I am looking into this, also added author name following topic link, now trying to turn them the right color and into links as is everywhere else forum-wide.
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: How to edit a Block of type Articles
« Reply #18 on: October 28, 2015, 02:51:34 AM »
Thanks, I am looking into this, also added author name following topic link, now trying to turn them the right color and into links as is everywhere else forum-wide.

You can use $article['poster']['link'], and it will display a link to the poster's profile and will be colored.

Offline ncoded

  • Semi Newbie
  • *
  • Posts: 33
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: How to edit a Block of type Articles
« Reply #19 on: October 28, 2015, 03:58:16 AM »
Yes, indeed. I used ['link'] instead of ['name'] and now everything's perfect. Thank you!
« Last Edit: December 29, 2015, 07:59:43 AM by ncoded »
SMF 2.0.11 | UTF-8 Language packs | GoDaddy Unix Shared Premium | SMF 2.1 b2 | Coppermine Gallery 1.5.38 | SimplePortal 2.3.6