Jump to content

Theme override at URL?


Nakamura RTS

Recommended Posts

Posted
7 hours ago, newbie LAC said:

Have you tested my code?

 Each link contain theme ID

I just did right now.

The link will only work by having the CSRF key produced. The way I want it is without the key, just the URL.

Posted
On 12/23/2018 at 8:24 AM, Brian A. said:

Okay. Is this correct?


{
	"topLevel": "",
	"pages": {
		"theme_theme": {
    		"friendly": "theme.php?theme={#id}",
    		"real": "app=themetreethemeid&module=theme&controller=theme"
		}
	}
}

The URL will be http://example.com/index.php?/theme.php?theme=X, right?

"friendly" should just be "theme.php" in this case. Query string parameters will work normally and don't need to be defined in the friendly URL (you'd only have to do that if you wanted to do something like "theme/{id}" or whatever).

Posted
4 hours ago, bfarber said:

"friendly" should just be "theme.php" in this case. Query string parameters will work normally and don't need to be defined in the friendly URL (you'd only have to do that if you wanted to do something like "theme/{id}" or whatever).

Okay, thanks for pointing that out to me.

I'm still having this issue where it keeps on throwing this error, "Cannot declare class IPS\IPS, because the name is already in use" in init.php.

Posted
9 hours ago, Brian A. said:

I just did right now.

The link will only work by having the CSRF key produced. The way I want it is without the key, just the URL.

If this for own site if so I have file does this without any app it hook but might hit issue as on ips cloud 

Posted
19 hours ago, Brian A. said:

Its not, it's for IPS cloud.

ah ok the file was design for my own use and because use self hosted option i never seen need make as plugin.

$_SERVER['SCRIPT_FILENAME']	= __FILE__;
$path	= '';
require_once $path . 'init.php';
\IPS\Session\Front::i();
if( \IPS\Member::loggedIn()->member_id )
{
	\IPS\Member::loggedIn()->skin = (int) \IPS\Request::i()->id;
	\IPS\Member::loggedIn()->save();
}
else
{
	\IPS\Request::i()->setCookie( 'theme', (int) \IPS\Request::i()->id );
}
/* Make sure VSE cookie is killed */
if ( isset( \IPS\Request::i()->cookie['vseThemeId'] ) )
{
	\IPS\Request::i()->setCookie( 'vseThemeId', 0 );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ) );

the file is stored in my root file but not sure any this can help you as very simple.

Posted
On 12/28/2018 at 7:09 AM, Pete T said:

ah ok the file was design for my own use and because use self hosted option i never seen need make as plugin.

I created the plugin and extended the class, \IPS\core\modules\front\system\theme and named the filename to "theme". But, when I go to the URL, it doesn't do anything besides redirecting the site to the root.

Is this the URL: /site/index.php?/theme/&id=4?

PS: I wrap the code inside the manage() method.

Posted
10 hours ago, Brian A. said:

I created the plugin and extended the class, \IPS\core\modules\front\system\theme and named the filename to "theme". But, when I go to the URL, it doesn't do anything besides redirecting the site to the root.

Is this the URL: /site/index.php?/theme/&id=4?

PS: I wrap the code inside the manage() method.

I check my URL but should be for me /themechange.php <-- the name of my file but will double check this.

Posted
On 12/29/2018 at 6:36 PM, Brian A. said:

I created the plugin and extended the class, \IPS\core\modules\front\system\theme and named the filename to "theme". But, when I go to the URL, it doesn't do anything besides redirecting the site to the root.

Is this the URL: /site/index.php?/theme/&id=4?

PS: I wrap the code inside the manage() method.

If I'm not mistaken, our default changetheme process uses /theme/ as the URL marker, and you can't define the exact same friendly URL marker. You'd need to do "theme.php" as you originally mentioned or something else that isn't taken already.

You know - an alternative solution might be to just extend the existing change theme process \IPS\core\modules\front\system\theme::manage() to override the method and basically skip the CSRF check (or force it to pass). This may be easier if your only end goal is to skip checking CSRF.

Posted
2 hours ago, bfarber said:

You know - an alternative solution might be to just extend the existing change theme process \IPS\core\modules\front\system\theme::manage() to override the method and basically skip the CSRF check (or force it to pass). This may be easier if your only end goal is to skip checking CSRF.

How would I go about this on my plugin?

Nevermind, I got it.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...