Jump to content

mr-fan

Members
  • Posts

    848
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by mr-fan

  1. flydev is right for the basic usage of the function with echo but additionally you define $pages but you did'nt that with $page: //you have this in your code... echo $page->title; so what is $page in this function? I think the whole idea is to build a function for the output of the basic page template...so i think this is the wrong way... I use in my templates the delayed output with a _main.php file (and _init.php and _func.php) and the interesting part different layouts on the equal templates...this idea is from @horst and the basic concept could read there: so you can split the template logic from the HTML output without to build a custom function for every template....since PW rendering the templates this is just unnecessary. You could build functions for special rendering that is needed in different templates or all over the place for example: /** * Show last Posts in several templates * @var $limit (Int) set the limit of displayed posts * @var $headline (string)set the headline of the postlist */ function renderArticles($limit = 3, $headline = 'New Articles') { //get articles $articles = wire('pages')->find("template=article,limit=$limit,sort=-publish_from"); if (count($articles)) { //get the rootpage of the articles $article_root = wire('pages')->get(1068); //open article list $out = '<h4 class="subtitle">'.$headline.' - <a href="'.$article_root->url.'">Overview</a><h4><div class="side-list"><ul>'; //get list items foreach ($articles as $a) { // get the image instance of the cropped version 70px x 70px $thumb = $a->artikel_bild->size(70); $out .= '<li>'; $out .= '<a href="'.$a->url.'"><img alt="'.$a->headline.'" src="'.$thumb->url.'"></a>'; $out .= '<h5><a href="'.$a->url.'">'.$a->title.'</a></h5>'; $out .= '<p>'.$a->article_cat->title.'</p>'; $out .= '</li>'; } //close list $out .= '</ul></div>'; return $out; } } Best regards mr-fan
  2. Thanks i will test asap. Thanks to netcarver - great addition!
  3. Is working here on a massive setup for blockbuilding....no affect so far.
  4. Hmm all looks good so far. One question - have you set the Textformatter on the field you wanna use this?
  5. for me it is working with 2.x and 3.x different versions....
  6. Oh i forgot the used fields you need...a headline field, a page select and a url field for internal and external links - so give this import file a try: https://github.com/mr-fan/TextformatterGlossary/blob/master/fields-example.json the whole system is very flexible since we use pages. for now there 3 different types of the glossary there that will be replaced if you look at the code it is very simple to know whats going on behind: //set the replacement depending from the item type switch ($entry->glossary_type) { case '1': //abbr $replacement = '<abbr title="' . $entry->headline . '">' . $term . '</abbr>'; break; case '2': //external link $replacement = '<a rel="help" target="blank" href="' . $entry->extern_link . '" data-original-title="' . $entry->headline . '"><span class="fa-globe" aria-hidden="true"></span> ' . $term . '</a>'; break; case '3': //internal link //internal link need to get the url $internLink = wire('pages')->get("$entry->page_link"); $replacement = '<a rel="help" href="' . $internLink->url . '" data-original-title="' . $entry->headline . '">' . $term . '</a>'; break; default: $replacement = $term; } it yould be possible to upscale the textformatter to use for footnotes, remarks or something else...;) regards mr-fan
  7. Or you could check the session user.... //get all posts from the user $posts = $pages->find("template=post, created_users_id=$user"); //check for permission in frontedn if($page->createdUser != $user) { //this is not your post! } regards mr-fan
  8. Hi, i've a one-man business and a bigger project on the run. A working prototype is already there. A budget pot is collected. Project sprecifications is a small webapplication that works as kind of mediation platform for farmers. Usage is limited to bavaria country. Customer is a Association for farmers. They will provide this tool to their members to solve some upcoming problems. Timeframe is to get a working solution at the end of the year and expand and adjust in the next years with some additional features. Since this is not a dead simple website project, i'm searching for a strategic partner for this project. Main work would done by me, but i will need assistance and experience in things like projectmanagment, refactoring, consultation and a partner that could take over the project if i become inoperative - there will be a payment only for beeing at standby. German language would be prefered but it is no requirement from the customer. Please write me a PM if you are wanna know more details. Best regards
  9. Thanks John, your workaround "works". Regards mr-fan
  10. A Question that is Hook related...since i'm not so familiar with hooks... I have a form from template "Entry" with some adress fields....and a checkbox for the creator of an entry to use his default adress in the entry...so the question is where or how i have to hook to change some values/fields depending on a checkbox...since all fields are set required. I need a hook before processing the form to check if the checkbox == 1 to set the needed adressfield values to the default values from the $user...than process the form inputs...don't know how to start. I've read your example hooks on bitbucket and tried some things but without luck. Best Regards mr-fan
  11. Some posts earlier i wrote i will give an detailed example of how you could use the Formhelper Module from pwFoo to create a register form an build the logic yourself if you need more complex setups. This is a stripped example from my register.php (please ignore the spelling while i've translated the most parts just quick and dirty for this post...) Best Regards mr-fan
  12. ...if i'm honest i was a little bit overwhelmed and lost, too. But for me is not really the platform itself important...ok performance and some things are but the really important thing is....the people who are running this are already here And with that community such optical things like the right balanced CSS and colours are only a question of time - to get changed in the right manner and style! Since this is more a opinion topic, this is mine. Regards mr-fan
  13. Ok - now with this last link you made a special xmas present in the middle of june... Thank you again for your useful hint. <ot>...I'm part of this forum for two years, using devns, read every week the interesting topics....and there are still so much hidden goodies </ot> best regards mr-fan
  14. Always like to learn new things about the API... but your code gives me a Call to a member function implode() on null error...? All sorted out your lession is great...no more need for such a PHP function...and replaced with a onliner + API call on implode()! Great thank you very much!! $page->yourPageField->implode(', ', 'title');
  15. I know this topic is kinda old... Since this is a othen find on google search on finding/handling first/last entries i will provide a little snippet that get pagefield titles prepared for needed output. Should just stay as very simple example for using first() and last() on this short thread... //get the page field titles right with a separating , $titles = ''; //count if we have more than one page in the page field if (count($page->mypagefield) == 1) { //we have only one page so get the first page title $titles = $page->mypagefield->first()->title; } else { //we have more pages in the pagefield so lets loop foreach ($page->mypagefield as $t) { //we need a , after every entry but not in the last one if ($t === $page->mypagefield->last()) { $titles .= $t->title; } else { $titles .= $t->title.', '; } } } //output will be "title1, title2, title3, lasttitle" best regards mr-fan EDIT: use arjen's example of implode() is in this case much more smarter....but the example above shows how to work with first() and last() so it will stay
  16. In fact all fields and values are kind of global.... Adrian has all summarized perfect - create a hidden page call it /settings/ or use a new fieldset tab named settings on the /home/ page and using a init.php is the most easiest way to get there - more complex is to setup your own config vars. In Processwire it completly depends on you where you put in data and pull it out - very flexible and at the beginning very overwhelming at least for me.....many options to choose from the start. Welcome to forums (this is the place very the options for your get sorted right) regards mr-fan
  17. If you take the red pill and go deep down the dark path of using devns....just kidding This module is definitive the best way to go http://modules.processwire.com/modules/process-wire-upgrade/ (Since every week there is a new dev version - upgrading with the module is a very easy thing and you could complete roll back.) Using the actual devns for a upcoming project and i think i'll be finished if the 3.x stable is there - then i will upgrade to stable and leave it on this version until i need other features or have a problem...but that are just my thoughts. regards mr-fan
  18. My favorite since years is http://komodoide.com/komodo-edit/ Had all i need to work for my simple dev skills.... together with the AutoCode addon i could setup PW and own functions like this and use it with autocompletion: $pages->find('[[%tabstop:selector]]'); entering pfind + TAB gets me the whole snippet...everything else like ftp, projectmanagment, autocompletion, todo lists (file/project), commandline, diff, is there...and it is much more faster than other IDE's and has not so much localisation problems like Atom or Brackets with german keyboard layout...
  19. Thank you for your hint...but i'm a just a poor spare time programmer...so very often in the late evening i don't get things sorted right It happens often that if i hit the "Post" button i change my mind and get the solution by my self.... $form->get("somefield")->required = true; // add only CSS class required to the field so simple get the "*" - NOT change the form processing/handling like // you set the field to required in the admin>field>settings!! Basic problem was the pass (password) field from the user template....in the admin i don't wanna change it to be required so i have to fill in on every change of the other user fields....and i have frontend forms to edit users profile...so on this frontend stuff i have to check for this field myself on processing and all is good. // get the input values for processing $email = $form->fhValue("email", "email"); $password = $form->fhValue("pass", "text"); // check for email duplication if (email_valid($email) == true) { // email exists $out .= message("email exists","danger"); } elseif ($password == ''){ // no password is there $out .= message("forgot to enter password","danger"); } else { //... // all is there so go process form Best regards mr-fan BTW i can't say it too often - your modules for Forms are really really great - have you known that the FormHelper Module even renders MapMarker Fields on frontend....usable!!
  20. Another question on this...if i setup some fields from a template like the user template. And i wanna set a field of this form required....i tried this like in forms from API: $form->get("pass")->label = "Change Password?"; //works $form->get("pass")->required = true; //works not How could i achive this or is there something missing in the FormHelper? Edit: All is working perfect....it just sets the CSS class to required not the $form input handling so i've to check manually this special fields... Best regards mr-fan
  21. Thank you very much - has a wrong encoding on my PHP Editor setup....so you saved my day! Best regards mr-fan
  22. Using WireSmtp for WireMail so far...so great...my question is more based on the basic WireMail thing i think but i'm not shure: using this call: $mail = wireMail(); $mail->to($u->email); $subject = '=?UTF-8?B?'.base64_encode('ÖÄÜ ö ä ü ß').'?='; $mail->subject($subject); $mail->bodyHTML($emailContentHtml); $mail->send(); i don't get german umlaute öäüß working in the subject?? I've read the forum and stackoverflow but this is the only solution everyone points out so i'm a little lost...how to debug or get it work. Best regards mr-fan
  23. @pmichaelis + @chugurk maybe my answer help both of you... i use MapMarker Field only in backend to get lat and long data from adresses and use them with leaflet cluster maps to generate frontend output from the geodata... in your main template or header add needed scripts: <!-- set extra scripts to load if there was a map on the page --> <script type="text/javascript" src="<?php echo $config->urls->templates?>theme/js/jquery.min.js" ></script> <script src="<?php echo $config->urls->templates?>theme/js/leaflet.js"></script> <script src="<?php echo $config->urls->templates?>theme/js/leaflet.markercluster.js"></script> <link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/leaflet.css"> <link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/MarkerCluster.css"> <link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/MarkerCluster.Default.css"> in your template to show the map with many markers using marker cluster output you could use something like this: //set output $map = ''; $addressPoints = ''; //get all addresspoints for the JS of the MarkerCluster $items = $pages->find("template=entry, map!=''"); foreach ($items as $m) { if ($m === $items->last()) { $addressPoints .= '['.$m->map->lat.', '.$m->map->lng.', "<a title=\"'.$m->title.'\" href=\"'.$m->url.'\">read more</a>"]'; } else { $addressPoints .= '['.$m->map->lat.', '.$m->map->lng.', "<a title=\"'.$m->title.'\" href=\"'.$m->url.'\">read more</a>"],'; } } //render cluster map with all items //centered to bavaria lat/long!! //set the needed inline JS for the map content $inlineJS = " <script> var addressPoints = [$addressPoints]; var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>' }), latlng = L.latLng(48.1835,11.8570); var map = L.map('map', {center: latlng, zoom: 8, layers: [tiles]}); var markers = L.markerClusterGroup(); for (var i = 0; i < addressPoints.length; i++) { var a = addressPoints[i]; var title = a[2]; var marker = L.marker(new L.LatLng(a[0], a[1]), { title: title }); marker.bindPopup(title); markers.addLayer(marker); } map.addLayer(markers); </script> "; $map .= '<div id="map"></div>'; $map .= $inlineJS; $content .= $map; This should render a map like the developer locations map http://directory.processwire.com/map/ with marker clusters... for single marker output there should be a lot of information in the topic if you search or read for it.... https://processwire.com/talk/topic/9711-map-marker-map/page-2#entry18338 https://processwire.com/talk/topic/9711-map-marker-map/page-2#entry21061 https://processwire.com/talk/topic/9711-map-marker-map/page-3#entry28913 since post #98 you could use MarkupGoogleMap too render a map on frontend: https://processwire.com/talk/topic/9711-map-marker-map/page-5#entry41984 please read carefully before asking and provide code examples if you get stucked.... best regards mr-fan
  24. Here is a little trick how a user the user template to manage things like a /profile/ page to frontend edit a users profile and this could be easy used for a own register logic and let the new user fill in all needed fields....the logic could be implemented via URL segments: //load module $fh = $modules->get('FormHelper'); // Template based form, skip fields 'title' and other adminfields, unstyled $form = $fh->create($templates->get('user'), array( 'notifications', 'admin_theme', 'language', 'roles', 'user_email', //this is where we fill a created token/hash to register the user and verifie via emaillink... 'confirm' //confirm link for an admin to set user created stuff puplic )); and in your template you could use URL segements for very simple or complex logic on registration - in my case i need to register a user but hide his content until an admin activated the user...email from the user itself should have to be validated, too so i've to build my own code here...since i wanna stick to just email + password and let the username created automatical in the background...this is just the basic for such a template nothing fancy here - maybe i wrote a little topic if it is running stable. Pseudocode for a template file register.php and URL's like: http://mysite.com/app/regsiter/URLsegment1/UserID/Hash http://mysite.com/app/register/activate/1235/fb5a44cfc2ecd8b5667a667319b66688 http://mysite.com/app/register/confirm/1235/d41d8cd98f00b204e9800998ecf8427e // we are using 3 URL segment, so send a 404 if there's more than 1 if($input->urlSegment4) throw new Wire404Exception(); switch ($input->urlSegment1){ case '': // segment 1 is empty so display normal content/register form // users could submit the register form and a new user is created two tokens are generated // email to the user and to admin // user is logged in and can add content - but the content will only published if // his two tokens are created on the first step to validate his email and confirm by an admin break; case 'activate': if ($input->urlSegment2){ // check for the user id if ($input->urlSegment3 == user_email) // check for the email token // user has get an email on submit the register form with a token link // and he hit this link so publish/activate the user and show him a message // delete user_email token break; case 'confirm': if ($input->urlSegment2){ // check for the user id if ($input->urlSegment2 == confirm){ // the user is confirmed by an admin and his content is published, delete confirm token break; default: // Anything else? Throw a 404 throw new Wire404Exception(); } This is just a example to how to rebuild the functions of the EmailValidation module in a flexible way with URL segments and some additional fields on the user template....AND the awesome form module from pwFoo... URL segments could setup with an regex in the template settings like this: regex:^[0-9]*$ //regex for user id regex:^[a-f0-9]{32}$ //reges for a hash/token If my project is finished i will provide more and detailed examples with templates and FormHelper! Best regards mr-fan
×
×
  • Create New...