Comments (12)
Very good question. That seems inconsistent.
It probably would be best to add a 'xoops_startpage' assign in \xos_opal_Theme::xoInit() so the theme could make the decision? It could default to 'system' as well. Also, should add the assign to redirect_header() for consistency.
Sounds like that would be a good upgrade.
Do you have any ideas? I would be happy to hear any alternatives.
from xoopscore25.
I think it's a good idea to put the variable 'xoops_startpage' assign in \xos_opal_Theme::xoInit().
How can we know if we are on the home page? use $_SERVER['PHP_SELF']?
from xoopscore25.
We could assign the config value for startpage to xoops_startpage, and assign xoops_script from the basename()
of $_SERVER['SCRIPT_FILENAME']
.
My first thought was xoops_requesturi would work, but it would take a lot of code to process in the template, since siteurl/ and siteurl/index.php both refer to 'home.'
$_SERVER['PHP_SELF']
can be corrupted by user input in some cases, i.e. siteurl/index.php/garbage/
That leaves us with $_SERVER['SCRIPT_FILENAME']
as the primary choice, and $_SERVER['SCRIPT_NAME']
as a fall back if SCRIPT_FILENAME isn't set.
That should make it easy to adapt as needed in the templates with no parsing or multiple values to check.
<{if $xoops_dirname == $xoops_startpage}>
- we are in the 'home' module
<{if $xoops_script == 'index.php'}>
- we are on the main page.
Would that work?
I also considered setting a $xoops_default_page variable as a boolean instead of using xoops_script might be simpler and cleaner. I am leaning toward the xoops_script, since it provides data to the presentation layer, so the logic stays in the templates, while the xoops_default_page idea makes a presentation decision and passes it to the template. But, either one would work.
from xoopscore25.
We already have it in System's preloads this:
if (is_object($GLOBALS['xoopsTpl'])) {
$GLOBALS['xoopsTpl']->assign('homepage', true);
}
So XOOPS can assign "$homepage", which then I can test in the theme to either assign the "one page" part of the theme, or the "module part":
<{if $homepage}>
<{includeq file="$theme_name/pages/home.tpl"}>
<{else}>
<!-- module part-->
<{/if}>
see the discussion in: http://xoops.org/modules/news/article.php?storyid=6734
Could we use this approach?
from xoopscore25.
Insraq also discussed this issue in his book "Design for XOOPS": https://goo.gl/DByanU
from xoopscore25.
I forgot that was there, but this approach solves a larger set of issues, so it would be more flexible.
I also considered setting a $xoops_default_page variable as a boolean instead of using xoops_script might be simpler and cleaner. I am leaning toward the xoops_script, since it provides data to the presentation layer, so the logic stays in the templates, while the xoops_default_page idea makes a presentation decision and passes it to the template. ...
The $xoops_default_page variable IS your $homepage.
Consider this example. Right now, with xBootstrap, it triggers off of <{if $xoops_dirname == "system"}>
to place the carousel for the home page. It also places that same carousel on each top level page that isn't part of a module, like register, inbox, view account. We are not currently providing a mechanism for the theme to control that without way too much work.
These issues are in addition to the problem of the carousel not showing on the landing page when you change the startpage.
I was actually considering the one page themes when I made this suggestion. Being able to interrogate both module and script in a standard way opens things up. Right now the one page themes are strapped on, not integrated to XOOPS. With this, in addition to a cool landing, you could for example do something special to target just the onboarding (registration) with a cool slick process, because you could target just that page.
Instead of making just one controllable page, this makes them all individually controllable. This is a superset, and what you already did could be readily accommodated. We can keep the $homepage variable (but maybe move its setup to the environment setup in xoInit().) But the longer I think about it, the more value I see in the proposed new variables.
There are more things needed, like some more flexibility with blocks and placement, like some things Eduardo is doing in RMCommon, but this would be a step forward all on its own.
from xoopscore25.
I am fine with whatever is more generic and flexible :)
from xoopscore25.
Me too!
from xoopscore25.
OK! @GregMage can you take this one?
from xoopscore25.
Ok, I'll make a proposal.
I can create a variable $xoops_page with more values. I use $_SERVER['SCRIPT_NAME'] to fill the variable $xoops_page.
Exemple:
in /htdocs/userinfo.php?uid=1 -------> $xoops_page = userinfo
in /htdocs/modules/xmcontent/viewcontent.php?content_id=38 -------> $xoops_page = xmcontent/viewcontent
The variable is initialized in xoInit().
I think it is simple and flexible.
what do you think?
from xoopscore25.
A first version: #197
Finally I use $_SERVER['SCRIPT_FILENAME']
from xoopscore25.
Hi,
ok and how to differentiate :
in /htdocs/modules/xmcontent/viewcontent.php?content_id=38 -------> $xoops_page = xmcontent/viewcontent
and
in /htdocs/modules/xmcontent/viewcontent.php?content_id=15 -------> $xoops_page = xmcontent/viewcontent
same $xoops_page.
I need this variable for the active attribut on bootsrap navbar
from xoopscore25.
Related Issues (20)
- Comment on a survey with Xoops default theme
- Profile config check HOT 2
- register.php have a bug HOT 1
- Duplicate content HOT 5
- The submenus are no longer displayed... HOT 2
- Break in Install HOT 3
- Problem with define "_DB_QUERY_ERROR HOT 4
- Missing icons in /modules/system/admin.php
- Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in F:\xampp\htdocs\xoops2511\class\libraries\vendor\smarty\smarty\libs\sysplugins\smartycompilerexception.php on line 8 HOT 3
- missing paypal image in renderAbout HOT 4
- extra quotation marks HOT 2
- XOOPS reads blocks from deactivated modules HOT 8
- PHP Version conflict HOT 1
- $GLOBALS['xoops']->path() and PHPUnit testing
- xoops website SSL issue HOT 1
- js problem with blocks
- USER has been deleted but it shows ERR~no redirection HOT 3
- Error with the PM module when deleting messages
- Undefined array key 1 in xoopskernel.php
- The dark and transition themes no longer work! HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xoopscore25.