Created
December 20, 2012 20:51
-
-
Save jeromecoupe/4348448 to your computer and use it in GitHub Desktop.
safecrachker and .htacess interactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. don't use these rules in your .htaccess if using the exclude method, they prevent safecracker forms from submitting properly. Sorry I forgot about thios. | |
# Add a trailing slash to paths without an extension | |
# ------------------------------------------------- | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ | |
RewriteRule ^(.*)$ $1/ [L,R=301] | |
OR add a rule not to add a trailing slash for POST requests | |
# Add a trailing slash to paths without an extension | |
# ------------------------------------------------- | |
RewriteCond %{REQUEST_METHOD} !=POST | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ | |
RewriteRule ^(.*)$ $1/ [L,R=301] | |
2. Update to ExpressionEngine 2.5.4 (nasty bugs with safecracker and EE 2.5.3) | |
<https://support.ellislab.com/bugs/detail/18233> | |
3. Here is the code for a simple "add and edit" form | |
It will add an entry if no entry_id is found in the URL as {segment_2} and will convert to an edit form if enrty_id is found. | |
a. rte_selector parameter: gives you the rich text editor instead of a plain textarea, must match a class in your code | |
b. return to the form itself and append the newly created entry_id as segment_2 | |
{exp:safecracker channel="blogs" status="open" entry_id="{segment_2}" rte_selector=".rte-editor" return="/safecracker/ENTRY_ID"} | |
<div> | |
<label for="title">Title:</label> | |
<input id="title" name="title" type="text" value="{title}" onkeyup="liveUrlTitle();" /> | |
</div> | |
<div> | |
<label for="url_title">URL Title:</label> | |
<input id="url_title" name="url_title" type="text" value="{url_title}" /> | |
</div> | |
<div> | |
<label for="summary">Summary:</label> | |
<textarea id="summary" name="cf_blog_summary">{cf_blog_summary}</textarea> | |
</div> | |
<div> | |
<label for="body">Body:</label> | |
<textarea id="body" name="cf_blog_body" class="rte-editor">{cf_blog_body}</textarea> | |
</div> | |
<div> | |
<input type="submit" value="Submit"> | |
</div> | |
{/exp:safecracker} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment