xoops forums

ghia

Community Support Member
Posted on: 2009/11/7 8:35
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#11

Re: How do I add a simple webpage to a xoops themed site?

Use a custom block, a blank module (eg ghost), a News category, a content module, ...
They all have permissions, that can be set to be viewed only by the targetted user group.

blackrx

Quite a regular
Posted on: 2009/11/7 9:06
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#12

Re: How do I add a simple webpage to a xoops themed site?

there is reason i want to use this.

i want it to be in my root

mysite.com/mypage.php

oh i made some search and i found this

$xoopsUser or redirect_header('index.php'3_NOPERM);


anonymous user will be redirect to index.php when they try to acces the page

but what about
Quote:

what if i want to restrict view of this page by user ID or by group ?


I don't want anonymous visitor or any other registered user to visit this page

how do i do this ?


what should i modify in the code

ghia

Community Support Member
Posted on: 2009/11/7 9:20
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#13

Re: How do I add a simple webpage to a xoops themed site?

if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.

demian

Quite a regular
Posted on: 2009/11/7 13:11
demian
demian (Show more)
Quite a regular
Posts: 225
Since: 2008/4/29
#14

Re: How do I add a simple webpage to a xoops themed site?

if anyone is interested here is how to add custom site name, page title,keywords and description to the original code



https://xoops.org/modules/newbb/viewto ... id=271870#forumpost271870


<?php
if (file_exists("mainfile.php")) {
include(
"mainfile.php");
} elseif (
file_exists("../mainfile.php")) {
include(
"../mainfile.php");
} else {
include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH."/header.php");
$xoopsTpl->assign'xoops_showrblock'1); // 1 = With right block - 0 = Without right block
$xoopsTpl->assign'xoops_showlblock'0); // 1 = With left block - 0 = Without left block
?>

HTML CONTENT GOES HERE

<?php

if(isset($xoTheme) && is_object($xoTheme)) {
$xoTheme->addMeta'meta''keywords'"keyword, keyword, keyword, keyword");
$xoTheme->addMeta'meta''description'"This is the page description");
$xoopsTpl->assign('xoops_sitename','This is the page title');

}
include(
XOOPS_ROOT_PATH."/footer.php");
?>



blackrx

Quite a regular
Posted on: 2009/11/7 13:29
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#15

Re: How do I add a simple webpage to a xoops themed site?

Quote:

ghia wrote:
if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.


i dont quite understand this...im quite newbie..thanks anyway Ghia


but i think i found a possible solution from this topic

will try if this works



blackrx

Quite a regular
Posted on: 2009/11/7 13:43
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#16

Re: How do I add a simple webpage to a xoops themed site?

<{if $xoops_isadmin}>
echo 
"test - admin see this";
<{/if}>

<{if !
$xoops_isuser}>
echo 
"user see this";
<{/if}>


<{if 
$xoops_isadmin}> <!--condition if the real webmaster login-->
echo 
"what to do";
<{elseif 
$group_id == 4}> 
//<!--condition if the other webmaster login ("4" is the id of the group created before)-->
echo "something to do if first condition is false and this condition is true";
<{/if}>
?>


i test some of this code but

it seems smarty tags is not working in my page

keep getting
Parse error: syntax error, unexpected '<'

ghia

Community Support Member
Posted on: 2009/11/7 14:13
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#17

Re: How do I add a simple webpage to a xoops themed site?

Do not mix Smarty code <{.... inside your PHP file. Smarty code is for templates, which need to be loaded by the PHP code first. No need to do that, this will make it only more complex.

If you use Demian's example, you have to place your HTML code by replacing 'HTML CONTENT GOES HERE '.

Before the first PHP ending tag ?> , you must do the validation for the access with PHP code.
With the code snippets I gave you, you can find out about the user his id or the groups he belongs to.
With these you have to do a check for failing (to meet the criteria) eg:
if (!$userisok) {
    
redirect_header(XOOPS_URL.'/index.php'3_NOPERM);
    exit();
}
This will prevent the user from seeing the page with a not permitted warning and bring him back to the home page.

script_fu

Friend of XOOPS
Posted on: 2009/11/7 17:46
script_fu
script_fu (Show more)
Friend of XOOPS
Posts: 1494
Since: 2002/12/27
#18

Re: How do I add a simple webpage to a xoops themed site?

This is interesting... Ghia will this code work in the root folder of Xoops?

Meaning

root/test.php?

So can I wrap a page with this code we have been using for years. Then add your code to where to get this working in the root folder not root/modules/test/test.php

Quote:

Northern wrote:
name it whatever you want, but end it in .php

<?php
if (file_exists("mainfile.php")) {
    include(
"mainfile.php");
}
elseif(
file_exists("../mainfile.php")) {
    include(
"../mainfile.php");
}
else {
    include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH "/header.php");
$xoopsTpl->assign('xoops_showrblock'0); // 1 display right blocks
$xoopsTpl->assign('xoops_showlblock'0); // 1 display right blocks
?>
///////
Your code in html 
///////
<?php
include(XOOPS_ROOT_PATH "/footer.php");
?>


or

in full php


<?php
if (file_exists("mainfile.php")) {
    include(
"mainfile.php");
}
elseif(
file_exists("../mainfile.php")) {
    include(
"../mainfile.php");
}
else {
    include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH "/header.php");
$xoopsTpl->assign('xoops_showrblock'0); // 1 display right blocks
$xoopsTpl->assign('xoops_showlblock'0); // 1 display right blocks

echo "Your code";

include(
XOOPS_ROOT_PATH "/footer.php");
?>


Marc


I didn't know user's could be controlled with stand alone pages.

Thanks for your time...

ghia

Community Support Member
Posted on: 2009/11/7 19:27
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#19

Re: How do I add a simple webpage to a xoops themed site?

Quote:
Ghia will this code work in the root folder of Xoops?
It seems to be designed to work in the root and up to two levels up.
Quote:
I didn't know user's could be controlled with stand alone pages.
With the right programming, you can do everything!

blackrx

Quite a regular
Posted on: 2009/11/8 0:36
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#20

Re: How do I add a simple webpage to a xoops themed site?

Quote:

ghia wrote:
if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.



Ghia can you show me example ?

so if i want so only user id=1 and 34 can access this page..what should i modify and put the user ID ?

if (!$userisok) {
    
redirect_header(XOOPS_URL.'/index.php'3_NOPERM);
    exit();
}


there is some possible solution here..
ban user from certain page

https://xoops.org/modules/newbb/viewto ... id=316663#forumpost316663

it will ban users defined in a table
.but this will be difficult...cause i want to ban all users except2 users

user id 1 and 34

how do i modify the code ?