[3.3][BETA] Custom Code

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Get Involved
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

leschek wrote:I would like to ask if you can add some kind of protection for edited files. When I updated "Custom code" (using "Upload extension" extension) it replaced edited files with new ones.
Thank you for pointing that out; I'll look into it.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

martti wrote:
leschek wrote:I would like to ask if you can add some kind of protection for edited files. When I updated "Custom code" (using "Upload extension" extension) it replaced edited files with new ones.
Thank you for pointing that out; I'll look into it.
This is solved now. When enabling, files are now checked wether they already exist or not.
leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [ALPHA] Custom Code

Post by leschek »

Great update
Thank you
Sippan
Registered User
Posts: 175
Joined: Thu Jan 27, 2011 6:23 am
Contact:

Re: [ALPHA] Custom Code

Post by Sippan »

Hi
I wonder if i do something in overall_header_content_before.html and i wont guest should see or is that not possible?
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

Sippan wrote:Hi
I wonder if i do something in overall_header_content_before.html and i wont guest should see or is that not possible?
If you want that anonymous guests don't see your content (if that is what you meant) then wrap your content in a conditional statement:

Code: Select all

<!-- IF S_USER_LOGGED_IN -->Anonymous guests won't see me<!-- ENDIF -->
Or, if you want to show a welcome message to Anonymous guests only (presuming it is a closed forum):

Code: Select all

<!-- IF not S_USER_LOGGED_IN --><h2>Welcome to our forum</h2><p>To view the topics, please take some time to register yourself and log in.</p><!-- ENDIF -->
You can use any of the available template variables. Other examples are:

Code: Select all

<!-- IF U_MCP -->Only moderators see me.<!-- ENDIF -->

Code: Select all

<!-- IF U_ACP -->Only administrators see me<!-- ENDIF -->
Sippan
Registered User
Posts: 175
Joined: Thu Jan 27, 2011 6:23 am
Contact:

Re: [ALPHA] Custom Code

Post by Sippan »

Thanks its just what i mean... is it possible to have this like an option in the extension?
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

Sippan wrote:Thanks its just what i mean... is it possible to have this like an option in the extension?
Use the editor to put any conditional statements. you can use them without problem in the files. Wrap your content into IF and ENDIF:

Code: Select all

<!-- IF [condition_variable] -->

Content here

<!-- ENDIF -->
User avatar
Walther
Registered User
Posts: 283
Joined: Fri Jul 09, 2004 5:21 pm
Location: The Netherlands

Re: [ALPHA] Custom Code

Post by Walther »

Love this extension, certainly with the extra conditions which can be set.
Just don't think it should be in [ALPHA] stage yet, but boy, love this extension.... :D
leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [ALPHA] Custom Code

Post by leschek »

I have question. I created menicko.html and menicko.css and added into overall_header_content_before.html
following:

Code: Select all

<!-- INCLUDECSS ../../../../../../store/customcode/menicko.css -->
<!-- INCLUDE ../../../../../../store/customcode/menicko.html -->
For some reason it load html file, but not css file. Then I changed INCLUDECSS into INCLUDE and it started work. It's probably because of my limited knowledges, but I thought that css files should be loaded by INCLUDECSS.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

leschek wrote:I have question. I created menicko.html and menicko.css and added into overall_header_content_before.html
following:

Code: Select all

<!-- INCLUDECSS ../../../../../../store/customcode/menicko.css -->
<!-- INCLUDE ../../../../../../store/customcode/menicko.html -->
For some reason it load html file, but not css file. Then I changed INCLUDECSS into INCLUDE and it started work. It's probably because of my limited knowledges, but I thought that css files should be loaded by INCLUDECSS.
The INCLUDECSS should go into overall_header_head_append.html, that's the correct place; then the css goes in the <head></head> where it should be; after the other styling. So it's possible to overwrite the styling. See the styling example I've added in the second post of this topic.
leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [ALPHA] Custom Code

Post by leschek »

Thank you, but, well, even your example doesn't work for me. The css file doesn't want to load. I can see the jpg file between files I can choose to edit. And I checked couple of times if I have everything in right place. It's interesting because I can see the files in source code (among css files added by extensions).
Here is the forum URL.

EDIT: When I click on link (css file) in source code it shows me "Internal Server Error"
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

I see the issue. Html files are cached, but other files are served directly. But Apache denies access because of .htaccess. I'm using php's internal development server which doesn't listen to .htaccess so I don't encounter this issue. So, I think I will take the /customcode directory outside the /store directory and put it straight into the root.
leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [ALPHA] Custom Code

Post by leschek »

Thank you,
It's working after update.

Idea - would be nice to have option to rename the files. I mean files can still have the same names, but I would like to use some kind of show names. So instead of overall_header_head_append.html it would show me main header for CSS or anything more clever you write in, but real file name stays the same.
I think in Pages extension they use this to choose location of a link.
User avatar
Walther
Registered User
Posts: 283
Joined: Fri Jul 09, 2004 5:21 pm
Location: The Netherlands

Re: [ALPHA] Custom Code

Post by Walther »

UPDATE issues:

- I disabled version 0.1.0
- backed up the customcode directory in ../store/customcode/
- deleted the content of /ext/marttiphpbb/customcode/
- uploaded the contents of the new version 0.1.1 in /ext/marttiphpbb/customcode
- pressed <enable>....

and got the next error:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 41: mkdir() [function.mkdir]: Permission denied

Warning: Cannot modify header information - headers already sent by (output started at /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions.php:3839) in /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions_acp.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions.php:3839) in /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions_acp.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions.php:3839) in /home/ocr/domains/ohcrap.com/public_html/forum/includes/functions_acp.php on line 132

manually made the new directory /forum/customcode/ , and tried to enable it again, to get the next error:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 53: file_put_contents(./../customcode/overall_footer_after.html) [function.file-put-contents]: failed to open stream: Permission denied
[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 53: file_put_contents(./../customcode/overall_footer_copyright_append.html) [function.file-put-contents]: failed to open stream: Permission denied
[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 53: file_put_contents(./../customcode/overall_header_content_before.html) [function.file-put-contents]: failed to open stream: Permission denied
[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 53: file_put_contents(./../customcode/overall_header_head_append.html) [function.file-put-contents]: failed to open stream: Permission denied
[phpBB Debug] PHP Warning: in file [ROOT]/ext/marttiphpbb/customcode/ext.php on line 53: file_put_contents(./../customcode/overall_header_stylesheets_after.html) [function.file-put-contents]: failed to open stream: Permission denied
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_acp.php on line 132: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3839)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_acp.php on line 132: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3839)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_acp.php on line 132: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3839)

...well, atleast it was working, but no files to be found in the /forum/customcode directory, so placed the contents of the backupped ../store/customcode/ in the /forum/customcode directory.

now...have to edit the files for the new includes now, I guess.
Found the store/customcode/ directory a way better place, to be honest.


Oh, by the way, there is a typo in language/en/common.php line 37:
'ACP_CUSTOMCODE_INCLUDE_EXAMPLE' => 'To include your own [color=#FF0000]croeated[/color] files, prepend the filename with <code>../../../../../../customcode/</code><p><code><!-- INCLUDE ../../../../../../customcode/my_file.html --></code></p>',


edit: and now during editing : The file overall_header_content_before.html is not writable.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [ALPHA] Custom Code

Post by martti »

Walther wrote:and got the next error:
Yes, that's right. You should get this error otherwise it would mean that your web root is writable, which is a securtiy issue.
Walther wrote:Found the store/customcode/ directory a way better place, to be honest.
Indeed, I agree. It's safer and it keeps the extension plug and play. So it'll be better limit the scope of the extension and just focus on template code. (You can still serve js and css files directly with INCLUDECSS or INCLUDEJS from other directories, but not edit these files in the extension's editor in the ACP).
I will revert back to /store/customcode later.
Post Reply

Return to “Extensions in Development”