SilverStripe page create error Class 'DateField' not found
Im creating new SilverStripe project based on the tutorial of SilverStripe.
After adding this code, the CMS field dont show and gives error.
class ArticlePage extends Page {
private static $db = array(
'Date' => 'Date',
'Author' => 'Text',
);
// .....
public function getCMSFields() {
$fields = parent::getCMSFields();
$dateField = new DateField('Date', 'Article Date (for example: 20/12/2010)');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');
$fields->addFieldToTab('Root.Main', $dateField, 'Content');
$fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
return $fields;
}
}
the error is:
Fatal error: Class 'DateField' not found in sample/sample/ line*
I don't see any problem with the code as I copy it from the tutorial itself. please help
See also questions close to this topic
-
How do I submit form without page reload taking into consideration the php script?
So basically I have to work on this loan calculator loancalc.000webhostapp.com
I have looked at other pages on this site "how to submit form without page reload?" but this isn't completely relevant to what i'm working on. So far i've added this into the jquery part of the page...
jQuery('qis-register').on('submit', 'input', function(){ event.preventDefault(); var name = $("input#yourname").val(); var email = $("input#youremail").val(); if (name == ""){ $("input#yourname").focus; return false; } else{ } if (email == ""){ $("input#youremail").focus; return false; } });
But i'm told there is also two other scripts that I need to work with, I'm not really too experienced with php so not sure what's going on, the two php scripts I have to work with are called quick-interest-slider.php and register.php,
//qis_verify_application in register.php function qis_verify_application(&$values, &$errors) { $application = qis_get_stored_application(); $register = qis_get_stored_application_messages(); $arr = array_map('array_shift', $application); foreach ($arr as $key => $value) { if ($application[$key]['type'] == 'multi') { $d = explode(",",$application[$key]['options']); foreach ($d as $item) { $values[$key] .= $values[$key.$item]; } } if ($application[$key]['required'] == 'checked' && $register['use'.$application[$key]['section']] && (empty($values[$key]) || $values[$key] == 'Select...')) $errors[$key] = 'error'; } $filenames = array('identityproof','addressproof'); foreach($filenames as $item) { $tmp_name = $_FILES[$item]['tmp_name']; $name = $_FILES[$item]['name']; $size = $_FILES[$item]['size']; if (file_exists($tmp_name)) { if ($size > $register['attach_size']) $errors['attach'.$item] = $register['attach_error_size']; $ext = strtolower(substr(strrchr($name,'.'),1)); if (strpos($register['attach_type'],$ext) === false) $errors['attach'.$item] = $register['attach_error_type']; } } return (count($errors) == 0); } //qis_process_application in register.php function qis_process_application($values) { global $post; $content=''; $register = qis_get_stored_register ('default'); $applicationmessages = qis_get_stored_application_messages(); $settings = qis_get_stored_settings(); $auto = qis_get_stored_autoresponder(); $application = qis_get_stored_application(); $message = get_option('qis_messages'); $arr = array_map('array_shift', $application); if ($message) { $count = count($message); for($i = 0; $i <= $count; $i++) { if ($message[$i]['reference'] == $values['reference']) { $values['complete'] = 'Completed'; $message[$i] = $values; update_option('qis_messages',$message); } } } $filenames = array('identityproof','addressproof'); $attachments = array(); if ( ! function_exists( 'wp_handle_upload' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } add_filter( 'upload_dir', 'qis_upload_dir' ); $dir = (realpath(WP_CONTENT_DIR . '/uploads/qis/') ? '/uploads/qis/' : '/uploads/'); foreach($filenames as $item) { $filename = $_FILES[$item]['tmp_name']; if (file_exists($filename)) { $name = $values['reference'].'-'.$_FILES[$item]['name']; $name = trim(preg_replace('/[^A-Za-z0-9. ]/', '', $name)); $name = str_replace(' ','-',$name); $_FILES[$item]['name'] = $name; $uploadedfile = $_FILES[$item]; $upload_overrides = array( 'test_form' => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); array_push($attachments , WP_CONTENT_DIR .$dir.$name); } } remove_filter( 'upload_dir', 'qis_upload_dir' ); $content = qis_build_complete_message($values,$application,$arr,$register); qis_send_full_notification ($register,$values,$content,true,$attachments); qis_send_full_confirmation ($auto,$values,$content,$register); }
function qis_loop in quick-interest-slider.php
function qis_loop($atts) { $qppkey = get_option('qpp_key'); if (!$qppkey['authorised']) { $atts['formheader'] = $atts['loanlabel'] = $atts['termlabel'] = $atts['application'] = $atts['applynow'] = $atts['interestslider'] = $atts['intereselector']= $atts['usecurrencies'] = $atts['usefx'] = $atts['usedownpayment'] = false; if ($atts['interesttype'] == 'amortization' || $atts['interesttype'] == 'amortisation') $atts['interesttype'] = 'compound'; } global $post; // Apply Now Button if (!empty($_POST['qisapply'])) { $settings = qis_get_stored_settings(); $formvalues = $_POST; $url = $settings['applynowaction']; if ($settings['applynowquery']) $url = $url.'?amount='.$_POST['loan-amount'].'&period='.$_POST['loan-period']; echo "<p>".__('Redirecting....','quick-interest-slider')."</p><meta http-equiv='refresh' content='0;url=$url' />"; die(); // Application Form } elseif (!empty($_POST['qissubmit'])) { $formvalues = $_POST; $formerrors = array(); if (!qis_verify_form($formvalues, $formerrors)) { return qis_display($atts,$formvalues, $formerrors,null); } else { qis_process_form($formvalues); $apply = qis_get_stored_application_messages(); if ($apply['enable'] || $atts['parttwo']) return qis_display_application($formvalues,array(),'checked'); else return qis_display($atts,$formvalues, array(),'checked'); } // Part 2 Application } elseif (!empty($_POST['part2submit'])) { $formvalues = $_POST; $formerrors = array(); if (!qis_verify_application($formvalues, $formerrors)) { return qis_display_application($formvalues, $formerrors,null); } else { qis_process_application($formvalues); return qis_display_result($formvalues); } // Default Display } else { $formname = $atts['formname'] == 'alternate' ? 'alternate' : ''; $settings = qis_get_stored_settings(); $values = qis_get_stored_register($formname); $values['formname'] = $formname; $arr = explode(",",$settings['interestdropdownvalues']); $values['interestdropdown'] = $arr[0]; $digit1 = mt_rand(1,10); $digit2 = mt_rand(1,10); if( $digit2 >= $digit1 ) { $values['thesum'] = "$digit1 + $digit2"; $values['answer'] = $digit1 + $digit2; } else { $values['thesum'] = "$digit1 - $digit2"; $values['answer'] = $digit1 - $digit2; } return qis_display($atts,$values ,array(),null); } }
Do I have to edit any of the php and I also don't know what I have to write considering the php.
-
How to make an upload form which requires rights
So I have a Php function in a form for file upload and I want to force people, that want to upload files, to log in. So if someone clicks on upload, an like in-window-pop-up comes up and he is forced to log himself in, or the upload will be canceled.
How do I do that?
index.html
<!DOCTYPE HTML> <html> <head> <title> File-Upload </title> <link style="text/css" rel="stylesheet" href="design.css"/> </head> <body> <div class="form"> <form action="upload.php" method="post" enctype="multipart/form-data"> <input class="select" type="file" name="datei"><br> <input class="upload" type="submit" value="Hochladen"> </form> </div> </body> </html>
upload.php
<?php $upload_folder = 'uploads/'; $filename = pathinfo($_FILES['datei']['name'], PATHINFO_FILENAME); $extension = strtolower(pathinfo($_FILES['datei']['name'], PATHINFO_EXTENSION)); $allowed_extensions = array('png', 'jpg', 'jpeg', 'gif', 'zip', 'rar', 'txt'); if(!in_array($extension, $allowed_extensions)) { die("Ungültige Dateiendung. Nur png, jpg, jpeg, gif, zip, rar und txt-Dateien sind erlaubt"); } $max_size = 1000*1024; //500 KB if($_FILES['datei']['size'] > $max_size) { die("Bitte keine Dateien größer 1000kb hochladen"); } $new_path = $upload_folder.$filename.'.'.$extension; if(file_exists($new_path)) { $id = 1; do { $new_path = $upload_folder.$filename.'_'.$id.'.'.$extension; $id++; } while(file_exists($new_path)); } move_uploaded_file($_FILES['datei']['tmp_name'], $new_path); echo 'Bild erfolgreich hochgeladen: <a href="'.$new_path.'">'.$new_path.'</a>'; ?>
I'm sorry for the German, but I think you can imagine what that would be in English.
-
How to load websites like netflix in PHP
I want to load Netflix on a website by my server. Like hide.me to avoid proxy blocks etc.
Now the problem is that I cant load it by iframe.
I just need my website to be like a little browser and load the website by the server. So when I open whatsmyip.com it should display the ip of my server not mine.
The problem is that I need to send data aswell so login etc works.
I can't use existing websites because they're tooo slow.
Do you guys know how to do a little browser-website?
-
Is there a way to turn on/off the logging with setting a variable in config file in SilverStripe 3.X (CWP 1.8)?
We are building a web application with CWP 1.8 which is upon SilverStripe 3.6, the log will be captured by SS_Log class with statement like SS_Log::log('Log message', SS_Log::INFO);. As we only need to capture the log for debugging purpose when the error happens, so we would like to make the logger more flexible that it can be controlled with a variable in the config file. In other words, we need to turn on the logging when the error produced and turn off the logging once the error sorted.
Can anyone give us some directions to achieve that? Thanks so much
SilverStripe 3.6
-
composer says ' [InvalidArgumentException] Package type "silverstripe-vendormodule" is not supported' while updating composer
Here what i'm doing
C:\wamp64\www>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 39 installs, 2 updates, 2 removals
Removing silverstripe-themes/simple (dev-master)
- Removing silverstripe/cms (3.0.x-dev)
- Installing silverstripe/recipe-plugin (1.3.0): Loading from cache
- Removing composer/installers (dev-master)
- Installing composer/installers (v1.6.0): Loading from cache
- Installing silverstripe/vendor-plugin (1.4.0): Loading from cache
- Installing symfony/polyfill-ctype (v1.10.0): Loading from cache
- Installing symfony/yaml (v3.4.22): Loading from cache
- Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache
- Installing symfony/translation (v2.8.49): Loading from cache
- Installing symfony/filesystem (v4.2.3): Loading from cache
- Installing symfony/config (v3.4.22): Loading from cache
- Installing symfony/polyfill-apcu (v1.10.0): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/log (1.1.0): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing symfony/cache (v3.4.22): Loading from cache
- Installing swiftmailer/swiftmailer (v5.4.12): Loading from cache
- Installing symfony/finder (v3.4.22): Loading from cache
- Installing marcj/topsort (1.1.0): Loading from cache
- Installing silverstripe/config (1.0.9): Loading from cache
- Installing ralouphie/getallheaders (2.0.5): Loading from cache
- Installing psr/http-message (1.0.1): Loading from cache
- Installing guzzlehttp/psr7 (1.5.2): Loading from cache
- Installing intervention/image (2.4.2): Loading from cache
- Removing silverstripe/framework (3.0.x-dev)
[InvalidArgumentException] Package type "silverstripe-vendormodule" is not supported
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] []...
here is my composer.json file
{ "license": "proprietary", "name": "silverstripe/installer", "description": "The SilverStripe Framework Installer", "require": { "php": ">=5.6", "silverstripe/recipe-core": "4.3.*" }, "require-dev": { "phpunit/phpunit": "~3.7@stable" }, "config": { "process-timeout": 600 }, "prefer-stable": true, "minimum-stability": "dev"
}
-
Is there any update for samthejarvis/silverstripe-watermarking in SS4?
I Try this module samthejarvis/silverstripe-watermarking on Silverstripe 4.3. I'm weak at php but I update some things for SS4 but i still have some Error. you can see the updates here