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: 733
  • 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]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: Custom Pages - help  (Read 5245 times)

0 Members and 1 Guest are viewing this topic.

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Custom Pages - help
« on: October 29, 2010, 10:29:07 PM »
Hello:
I'm still new to php and need some help with this. I want to make a custom php block that will list the pages I have created. Below is the code I have found posted by the master builder of SP. This works great, but I need it to only list certian pages. I figure I can pull this off by creating pages I want to list togeter by giving them the same starting title.
Example - Football players, Football Teams, ect...
If someone could modify/add the code I would need to make this happen it you would make my day.  :thumbsup:

Thank you


Quote
global $scripturl;$pages = sportal_get_pages(null, true);echo '<ul>';foreach ($pages as $page)   echo '   <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';echo '</ul>';

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #1 on: November 01, 2010, 12:52:54 PM »
http://www.w3schools.com/php/php_if_else.asp
http://www.php.net/manual/en/language.control-structures.php
 
Code: [Select]
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';
 
foreach ($pages as $page) 
{
    if (....)
        echo '   <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';
}
 
echo '</ul>';

Only -- you need to replace the '....' with the conditions you want to use to control which pages you want to see. Look in function sportal_get_pages to see what information the function returns, and construct a logical expression to use that information the way you want to use it.
 
 
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Page ID
« Reply #2 on: November 02, 2010, 08:10:57 AM »
Hello:

I was wondering what - Page ID is? Exactly what would you use it for?
I'm guessing it might be some kind of script calling feature?
I have searched the forum, and it's not really explained so I thought I would ask

Please forgive me if this post is in the wrong place I was not sure where to post it.

Thnaks

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page ID
« Reply #3 on: November 02, 2010, 11:29:23 AM »
Grasshopper, it is within yourself to answer this question.
 
It is a natural next-step as you figure out how to solve the puzzle you created in your previous topic, and could have been written as a reply to that topic.
 
Here is my suggestion: look at the information available about simpleportal pages in order to gain enlightenment about how SimplePortal keeps track of pages.
 
For example, you can copy this code into a custom php block and hit the preview button to see some of the information about pages.  If you are curious about more of the information about pages, look at the function sportal_get_pages to see which information it retrieves about the pages.
Code: [Select]
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>
';
 
foreach ($pages as $page) 
{
           echo '   <li>page_id: ', $page['page_id'], ', title', $page['title'], '</li>
';
}
 
echo '</ul>
';

 
 
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Page ID
« Reply #4 on: November 02, 2010, 11:36:15 AM »
Page Id is an alphanumeric id unique to every page used as an alternative to numeric ids. For example the Blocks In Blocks Sample page here can be accessed by both the page id and regular id:

http://simpleportal.net/index.php?page=blocks_in_block_sample
http://simpleportal.net/index.php?page=4

An alphanumeric id would be useful if you are using something like Simple SEF or Pretty URLs to display pretty links for pages easily. It looks prettier than numeric ids.
And slowly, you come to realize... It's all as it should be...

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #5 on: November 02, 2010, 01:02:02 PM »
Ok I'm close on this I thnk but I still need a help/push off cliff...
What I posted below lists all the pages and not just the one I want, but all the links goto the page I want. So whats the problem? Lost sole....

Quote
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';

foreach ($pages as $page)
if ($page['page_id']='superman') {
echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';

}
echo '</ul>';
« Last Edit: November 02, 2010, 01:11:38 PM by The Wizard »

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #6 on: November 02, 2010, 01:18:43 PM »
YEA!!! Found the Answer -

Quote
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';

foreach ($pages as $page)
if ($page['page_id']=='superman') {
echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';

}
echo '</ul>';

I did not have two == ahhhhh
anyway above is the completed code for all those that follow me...

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #7 on: November 02, 2010, 01:26:06 PM »
It's me again  :'(
this only works with one page....
I wanted it to sort more them one page....

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: Custom Pages - help
« Reply #8 on: November 02, 2010, 01:55:58 PM »
I have expanded your code for multiple pages. To add more, simply append a new line into the array, surrounded by single quotes, and with a comma at the end.

Code: [Select]
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';

$pages_to_show = array(
'superman',
'someotherpage',
'etcjustkeepaddingyourpageshere',
);

foreach ($pages as $page)
{
if (in_array($page, $pages_to_show))
echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';

}
echo '</ul>';

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #9 on: November 02, 2010, 02:09:24 PM »
Quote
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';
foreach ($pages as $page)
for ($n = 0; $n < count($pages);
$n++){
if ($page['page_id']=='who'."$n") {
echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';
}
}
echo '</ul>';

Here is a new and inproved code. I added a counting code in. Now all you have to do is title your page ids - example who1, who2, who3, ect and it will list all those pages and display links to them.
 

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #10 on: November 02, 2010, 02:21:02 PM »
Note: the counting code has a flaw in it. It counts the number of pages you have created so if you have named your id a high number it will not show up. I'm working on a fix now. hope to post soon

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: Custom Pages - help
« Reply #11 on: November 02, 2010, 02:42:49 PM »
I don't see why you even need to use count() for... what are you trying to do?

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #12 on: November 02, 2010, 03:01:29 PM »
Quote
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';

foreach ($pages as $page)
for ( $counter = 0; $counter <= 50000; $counter += 1) {

if ($page['page_id']=='who'."$counter") {
echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';

}

}
echo '</ul>';

Ok this is the fixed counting code should work fine unless you have over 50,000 pages then just change the count number.

Offline The Wizard

  • Semi Newbie
  • *
  • Posts: 32
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #13 on: November 02, 2010, 03:08:20 PM »
I don't see why you even need to use count() for... what are you trying to do?

I have a ton of information on my BB and want to organize it into easy to find web pages (To be honest I don't like the articles system as it is now). I'm trying to automate the process so I don't have to work so hard.
To do this I need some way of calling up all diffrent pages into sections. I know this is not want most users need, but I do. I wish to thank everyone who helped me with this. I hope that posting my notes/code here it may help one person out later.

The Wizard

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom Pages - help
« Reply #14 on: November 02, 2010, 04:18:28 PM »
Code: [Select]
global $scripturl;
$pages = sportal_get_pages(null, true);
echo '<ul>';

foreach ($pages as $page)
 {

if ( substr($page['page_id'],0,2)=='who')  echo ' <li><a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></li>';

}

echo '</ul>';
« Last Edit: February 15, 2011, 12:39:11 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?