Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-01-26 09:43:39

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

clientside and serverside plugin development

Can the two be created within one plugin?

I want to produce a tag that outputs data into a website and the data to be managed via the txp backend. But I can’t get it to work with one plugin, I have to create 2, one serverside and one client side

Offline

#2 2011-01-26 09:48:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: clientside and serverside plugin development

leafy_loader wrote:

Can the two be created within one plugin?

Certainly. Set the plugin type to 1 (Public + Admin) and it’ll be loaded on both sides (the plugin composer allows you to do this via a radio button). Then it’s just down to setting your callbacks appropriately. You can detect from which side your plugin is being called with:

if(@txpinterface == 'admin') { ... }

and set your admin-side callbacks there.

Last edited by Bloke (2011-01-26 09:49:25)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#3 2011-01-26 09:53:03

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

Re: clientside and serverside plugin development

That’s what I did but I get the following;

Fatal error: Call to undefined function pagetop() in c:\program files\apache group\Apache\htdocs\temp_site\fiscal_cms\textpattern\lib\txplib_misc.php(638) : eval()’d code on line 16

Offline

#4 2011-01-26 09:57:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: clientside and serverside plugin development

leafy_loader wrote:

Call to undefined function pagetop()

Weird, that should always be available on the admin side (it’s not available on the public side of course). Can you share a snippet of code on how you set up your admin-side callbacks and the function it’s calling where the pagetop is?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#5 2011-01-26 10:00:40

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

Re: clientside and serverside plugin development

I think it’s because I hadn’t enclosed all the admin functions within if(@txpinterface == ‘admin’) { …

Not getting the error now I’ve done that

Offline

#6 2011-01-26 10:03:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: clientside and serverside plugin development

leafy_loader wrote:

I think it’s because I hadn’t enclosed all the admin functions within if(@txpinterface == ‘admin’) { …

That would certainly fix it! In theory you don’t need to wrap the functions themselves in the conditional — just the setting up of the callbacks. The functions shouldn’t be called at all if the callbacks aren’t set so it should never try and run those functions anywhere other than the admin side.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#7 2011-01-26 10:45:00

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

Re: clientside and serverside plugin development

The only thing thats not working is the client side

Offline

#8 2011-01-26 10:52:04

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

Re: clientside and serverside plugin development

Oops, it is working. My fault, typo doh!

Thanks for your help Bloke

Offline

Board footer

Powered by FluxBB