News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Adding a custom page manually for Smf 2.0. rc 3

Started by cicka, July 11, 2010, 12:40:47 PM

Previous topic - Next topic

cicka

I changed the ban part spottedhog, thank you for the reminder :)

Yoshi2889, there is no need to install a mod for this because if the edits are done properly there will be no errors at all :)

NanoSector

Quote from: cicka on July 12, 2010, 10:26:34 AM
I changed the ban part spottedhog, thank you for the reminder :)

Yoshi2889, there is no need to install a mod for this because if the edits are done properly there will be no errors at all :)
I mean if a mod modifies Subs.php it will be all fine when you get errors.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

divecall

How i can do, that this new page is only visible for logged members, not guests ?

spottedhog

#23
Enclose the page content with:

global $context;
if($context['user']['is_logged'])
{

// page content here

} else {
ssi_login();
}


Of course you can replace ssi_login(); with whatever you wish to use there.

Matthew K.

If the page uses a Source File, it is better to do it in the source file, rather than the template.
Quote from: spottedhog on August 02, 2010, 06:35:15 AM
Enclose the page content with:

global $context;
if($context['user']['is_logged'])
{

// page content here

} else {
ssi_login();
}


Of course you can replace ssi_login(); with whatever you wish to use there.

cicka

Quote from: divecall on August 02, 2010, 04:16:46 AM
How i can do, that this new page is only visible for logged members, not guests ?


If you are using the codes from my original post find this code:

//Here is the content, such as the title and the body message of the custom page.

echo'
         <span class="clear upperframe"><span></span></span>
         <div class="roundframe"><div class="innerframe">';
         echo'
         <div class="cat_bar">
         <h3 class="catbg">Hello everyone</h3>
         </div>
          <p>This is a custom page example. pretty cool, huh.</p>';
         echo'
         </div></div>
        <span class="lowerframe"><span></span></span>';   




And change it to this code

global $context;
if($context['user']['is_guest']){
echo
fatal_lang_error('no_access', false);
}else{
echo'
         <span class="clear upperframe"><span></span></span>
         <div class="roundframe"><div class="innerframe">';
         echo'
         <div class="cat_bar">
         <h3 class="catbg">Hello everyone</h3>
         </div>
          <p>This is a custom page example. pretty cool, huh.</p>';
         echo'
         </div></div>
        <span class="lowerframe"><span></span></span>';   
}


KensonPlays

Quote from: Labradoodle-360 on July 11, 2010, 04:40:26 PM
Another easy way you can accomplish a "Custom Page" is by creating a custom action...very simple with no SSI necessary.

Yes, that mod works well! Although for some reason it doesn't work on my end the add action button doesn't work as well a sub-action link. :(

Owner of Mesozoic Haven

yfleury

I need permission or membergroup to show different content to guest, regularmember and specialmember

I use this
global $context;
if($context['user']['is_guest']){
      echo 'this is for guest';

}else{
      echo 'this is for regular member';   
      // I have to do a if here to show a content for special member
     if (What to put here){
            echo 'this is for special member';
     }
}
SMF 2.0.6

yfleury

I find it myself.... look like this

global $context;
if($context['user']['is_guest']){

      echo 'this is for guest';

}elseif(in_array(1,$user_info["groups"] )==1) { // number 1 = admin

       echo 'this is for admin';

}elseif(in_array(9,$user_info["groups"] )==9){ // number 9 = special member

echo 'this is for special member';

}else{

        echo 'this is for other member';

}


To find what number for different member groups, look at smf_membergroups table in the database  and when you find a member groups you want, take the number in id_group.
SMF 2.0.6

RoflGuy

how do i add the page i made to the menu bar , which got Home , Forums and others?

NanoSector

This forum just knows what I want to read...then my SMFTools topic pops up as unread when I want to review it and then this topic pops up when I need it :P

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

DutchJam

Hi,

Created a custom page with the code above and it works perfect.

But when I installed the SimpleAds mod to dislplay ads on my site I get this error message on my static page:

Fatal error: Call to undefined function template_ad_position() in /public_html/Sources/Load.php(2156) : eval()'d code  on line 228

This message only appears on the static page. All others work perfect.

Anyone know how to solve this?

Thanks!
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

spottedhog

You will need to "include" the file that contains the SimpleAds function.

DutchJam

Quote from: spottedhog on November 19, 2010, 07:36:30 AM
You will need to "include" the file that contains the SimpleAds function.

Into the static page?

And how?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

spottedhog

#34
I just took a look at that mod and here is what I see:

require_once($sourcedir . '/Subs-Ads.php');

Where $sourcedir = path to the Sources folder.

DutchJam

Quote from: spottedhog on November 19, 2010, 08:57:15 AM
I just took a look at that mod and here is what I see:

require_once($sourcedir . '/Subs-Ads.php');
   load_ads();

Where $sourcedir = path to the Sources folder.

Oh, I get it. I added the code to the static page and now it works again.

But I have to do this to every static page of course.

Tnx Spottedhog, problem solved!

-----
JamaicaForum.nl: http://www.jamaicaforum.nl

spottedhog

:)  OK, consider this...  using the same principle, you can now use any of the SMF functions on your static pages.  Keep in mind that SSI.php only pulls in variables and the functions within that file. Soooo, you can find functions you may need in one of the Sources files, require/include it, and then be able to use the function.

This is the base premise for nearly all PHP coded software.  :)

NanoSector

I've recently got the require(./ssi.php) thing work so it points to the one in my forum folder...no more copying files for me!

For 000webhost members:
require("/home/ayouraccountnumber/public_html/forum/SSI.php");
Where youraccountnumber is your number like 1234567, and forum/ is your directory where SSI.php is located.

Place that in all of your pages and it works fine :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

spottedhog

A better way is to view your ssi_examples.php file in your web browser and use the path shown in the "Include Code" section (relative to where your static page is installed)

NanoSector

Quote from: spottedhog on November 19, 2010, 05:05:22 PM
A better way is to view your ssi_examples.php file in your web browser and use the path shown in the "Include Code" section (relative to where your static page is installed)
.......if you had said that before you would have saved me time..........
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Advertisement: