Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/23/2014 in all areas

  1. Update: versions 0.0.4 - 0.0.6 Versions 0.0.4 - 0.0.5: Code changes. Version 0.0.6: Added ability to copy-paste CSV values to save to current page Wasn't sure whether ability to import from CSV values in this manner really belonged in a Fieldtype and was wondering whether I should make the feature configurable optionally available? Then again, it makes sense in a fieldtype whose primary purpose is to store excel/grid-like data! Anyway, for now it stays...Will think about adding feature to import from csv/txt file... Copy paste CSV Data
    5 points
  2. @BernhardB Ah, thank you for your many tips! I am learning fast by doing things wrong I am trying your improved code suggestion now... UPDATE: It worked! Successful result: Below is a breakdown of the steps I took in very simple terms for other beginners to follow (all credit to previous posters, especially @Horst and @BernhardB - you are truly patient ). Steps for creating random quote/text selection from a large pool (for an absolute beginner) All steps are completed through the ProcessWire admin panel, unless otherwise stated. These steps assume you are using the _main.php and _init.php files in your templates. Build a page called tools. This serves as a parent for stuff that is not used to be displayed directly in the frontend. Assign this page the pw_default template. Set the page to hidden. When saving this page, choose 'save + keep unpublished'. Create a new template called quote_category. This template only needs one field: title. Later, you will use the title field of this template to enter categories you want to use to classify quotes. Note: this is different to @horst's suggestion of a generic category field only for scalability - if you need to make other categories for other types of information in the future, and don't want them both to be called by the same function. In the code editor of your choice, create a file called quote_category.php. In the body of the file, enter: <?php // quote_categories.php template file Save this file to your computer. Using an FTP program, upload this file to your processwire installation at: site/templates/. Create a page under tools called quote_categories. This serves as parent for the categories you use to classify your quotes. Assign this page the pw_default template. Set the page to hidden. When saving this page, choose 'publish'. Under the page quote_categories, create child pages. Assign each child page the quote_category template. In the title field of each new child page, enter the name of one category you need. For every child page, set the page to hidden. When saving each child page, choose 'publish'. Create as many child pages as categories you need. Create some fields to be used on a new template (see next step): field label: Quote text field name: quote_text field type: textarea or text (depending on how long your quotes are, and how much formatting they require) field label: Quote Author field name: quote_author field type: text field label: Quote Category field name: quote_category field type: page Note: for this field, there are extra settings required - you can find them under the 'Input' section of field options. input field type: ASMselect* parent of selectable pages: /tools/quote_categories Any other field you need. For example, I have a quote_reference field to cite where the quote came from. This is not necessary though. Create a new template called quotes. Add the templates you just created to this template: quote_text, quote_author, quote_category and any others you made. In the code editor of your choice, create a file called quotes.php. In the body of the file, enter: <?php // quotes.php template file // Primary content goes here $content = "'" . $page->quote_text . "'". "—". $page->quote_author . "<br>" . "$page->quote_category"; Save this file to your computer. Using an FTP program, upload this file to your processwire installation at: site/templates/. Create a page under tools called quotes. This serves as parent for all single quote pages. Under the page quotes, create child pages. Assign each child page the quote_category template. When saving each child page, choose 'publish'. Create one child page for every quote you have. In an FTP client, download the template where you want a random quote to appear. In your code editor of choice, open the template where you want a random quote to appear. Enter the the following code: $quote = $pages->find("parent=/tools/quotes, quote_category.title=category1|category2")->getRandom(); //add nice formatting $quote_w_heading = "quote: '" . $quote->quote_text . "' —". $quote->quote_author; In the above example, replace the text 'category1|category' with the name of the category/ies you want to display a quote from. Then, at the $content or $sidebar function (or wherever you want your quote to display), add the following code to the end of the string: . $quote_w_heading So the $content string should look something like this: // Primary content goes here $content = $course_number_w_heading . $course_summary_w_heading . $recording . $quote_w_heading; Save your template file. Upload it back to to site/templates/ In your browser, view a page that uses the template you just changed. Refresh the view, and marvel at your new random quote appearing! Now that I have written out all these instructions, I see that this is perhaps not a beginner project. More experienced people, please offer corrections to any steps you see that could be improved. Thanks again all for your help!
    4 points
  3. Updated the README and Screenshots on GitHub. Should be really nice to use now: https://github.com/LuisSantiago/FirstSteps/ I also splitted this module to allow third-party modules to use this feature (examples are on github).
    4 points
  4. Well explained. It's really important when you're learning a new system to be completely comfortable with the terminology. If the words used to describe something doesn't gel with you, then you're not going to absorb the concept. Reminds me many years ago of trying to learn expression engine when everything in the tutorial book (and Expression Engine) was called a blog. I didn't get it (at the time) until EE 2 came out and their internal terminology changed. So these days, to counter getting hung up on a keyword or label which I find confusing, I will treat a word as an anagram instead. IE Instead of thinking "its a page", imagine it's a P.A.G.E and make up your own meaning for this such as Part of Anything Going to be Edited Pod for All your Generated Entries Place Already Great for Expansion I'm sure there's better possibilities but it may help. Or it may make things worse :-/
    4 points
  5. Update for bug fixes and small feature additions. An upgrade might introduce breaking changes, the user should be informed about that. Perhaps add an additional field somewhere (dunno where and how yet) where the module author can define a breaking changes notice or something. So if a user clicks upgrade, the notice is fetched from the modules directory and thrown at the user. Just my initial ideas about that topic.
    3 points
  6. Not to be pedantic, but you can actually do this. It can be a bit of a shortcut way of assigning things to variables. That said, I generally think it looks confusing and ugly, but can occasionally be useful, but not in this case since you aren't using $quotes anywhere else $quote_w_heading = "Quote goes here: " . $quotes = "The quote"; echo $quote_w_heading; You would end up with: Quote goes here: The quote and $quotes would equal: The quote
    3 points
  7. it's better to post your code as text, not as image - so we can copy/paste it just quick, not tested - try something like this: $quote = $pages->find("parent=/tools/quotes, quote_category.title=life")->getRandom(); // quote is now your random quote page with all its fields // i don't know what fields you have? title / body / ...? $quote_w_heading = "quote goes here: " . $quote->title; // or $quote->body you can't have 2 equal signs on one line $this = $is . $correct; $this = $is . $not = $correct;
    3 points
  8. Hey @Ledzepman, here is a good reading about how to deal with urlSegments: https://processwire.com/docs/tutorials/how-to-use-url-segments/ And if you not already know it, best search results do you get with google like this: // searches the whole PW site https://www.google.com/search?q=site:processwire.com+urlsegment // only search in forum posts https://www.google.com/search?q=site:processwire.com/talk+urlsegment --- regarding to the check if a county page exists and taking the example from ryans tutorial, you can do it like this: // we are only using 1 URL segment, so send a 404 if there's more than 1 if($input->urlSegment2) throw new Wire404Exception(); // now check if there is no urlSegment1 if($input->urlSegment1 == '') { // display main content ... } else { // get you a PageArray of all county pages using a appropriate selector. This depends on how you have setup things $countyPages = $pages->get("/path/to/countyparentpage/")->children(); // build an array of what you need to validate, titles or names ? (I use their names in the example here) $validCounties = array(); foreach($countyPages as $cp) { $validCounties[$cp->name] = $cp->name; } // now check if it is a valid county if(isset($validCounties[$input->urlSegment1])) { // display county content ... } else { // unknown URL segment, send a 404 throw new Wire404Exception(); } }
    3 points
  9. This module displays tutorials according to the page where you are (based on intro.js). It also displays useful links. It is in process. Suggestions and reviews are welcome. To test the module go to modules or pagelist after install. Done: - PageList - Modules To Do: - Access -User, Roles, Permissions - Setup -Templates -Fields -Languages -PageEdit -Search Github
    2 points
  10. I have found !! There was a javascript conflict with the google analytics code !!
    2 points
  11. hi kathep, the error comes from horsts code snippet (feeling a little embarassed to correct him ) $pages->get->("/tools/quotes/") should be $pages->get("/tools/quotes/") see the docs about selectors: https://processwire.com/api/selectors/ and a hint on how to efficiently search the forum with google: https://www.google.at/search?q=site:processwire.com+random&gws_rd=cr&ei=RnSZVKnFAcH9UP35gbAL (see the howto in my signature)
    2 points
  12. +1 for the idea. For the implementation, I'd suggest encouraging module authors to implement Semantic Versioning or similar strategy; no need to include special flags, fields, etc. when version number itself clearly states if there's a (potential of) breaking change.
    2 points
  13. As mentioned, add a page field to the user where you will specify the pages the user has access to. In the appropriate place (this could be the template, or else) add a function (this should be the first piece of code to execute, before any rendering) ) to check if the current page id matches one of the pages in the user's allowed page list. If the match is negative, redirect the user somewhere else. If it is positive, let the page continue to execute. I would gladly give you some code example but being on my phone right now makes it sort of hard. Hope this clears it up for you.
    2 points
  14. May someone else finds this helpful. I wanted to create comments (using built-in comments fieldtype module) via API, as I needed this is for an easy migration from an existing site. I figured following does the job: <?php // get the page that you want to add comment(s), contains a "comment" fieldtype $p = $wire->pages->get("/guestbook/"); // create new Comment object $c = new Comment(); // fill the object with values $c->text = "Hello World!"; $c->cite = "John Average"; $c->created = time(); // timestamp, if you got to migrate a existing datetime you can convert using strtotime("2011-04-09 15:14:51") $c->email = "john@average.com"; $c->ip = "..."; // not needed (only for akismet) $c->user_agent = "..."; // not needed (only for akismet) $c->created_users_id = "..."; // not needed, automaticly set by pw // set status (Spam = -2; Pending = 0; Approved = 1; ) $c->status = 1; // add new comment object to the page "mycomments" field $p->mycomments->add = $c; // save page $p->save(); ?>
    1 point
  15. This afternoon i was setting up a new laptop with Win7 64bits. Having used it in the past with no problems i decided to use Wampserver 2.5 to setup my webdev environment. Having set up an existing project and a vanilla PW install i noticed that some front-end pages took quite long to respond/render. After logging in i also noticed this in the back-end. Especially opening a template edit page performed bad, with a noticeable 2 to 3 seconds delay in the response. This was not at all the case with the live site running the same code base. After some hair-pulling i discovered that it was xdebug slowing things down. In Wampserver it comes bundled with the following settings in php.ini (to which i added the max_nesting_level because the default 100 will cause problems in PW) : ; XDEBUG Extension zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll" ;xdebug xdebug.remote_enable = off xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir = "c:/wamp/tmp" xdebug.show_local_vars=0 xdebug.max_nesting_level = 200 After commenting out all of the above, basically disabling xdebug altogether, my PW installs where back to normal, snappy performance. Because i don't use xdebug for debugging or profiling i'm fine with totally disabling it. This might be a tip for people experiencing bad performance in relation to xdebug. What i do find surprising is that with the above settings no actual debugging/profiling is enabled. The only thing xdebug needs to do is collect info for it's stack trace. Would this really cause such slowdowns?
    1 point
  16. Two days ago, an idea about a new admin theme came to my mind. Some hours later, I've crafted a first concept in Adobe Fireworks.... The look and feel of the admin is important Two months ago, I've introduced some teachers into ProcessWire. They were none-technically people. At the end, they knew how to use the admin panel to create content or update a gallery on their new page. However at some points, they got confused with parts of the admin theme -beside the problems with our concept on how to use fields and templates for creating content. I think one factor why Wordpress became so large, was the great Adminpanel. It works well and easy (as long as you have a blog and not a twenty-plugins-for-text-pages-site). Editing content on a daily basis is the main task of my customer. I've to take this aspect serious. Problems I wanted to solve Have the page tree always visible. If I do not click the right link, it will be closed after I've finished editing my site More visuals like icons. Simplify some workflows. Creating 3 or 4 pages can result in multiple unnecessary clicks. More focus on important links like the tabs. Guide my customer through some action. Help them to repeat simple tasks. The concept First: Nothing is perfect and its not possible to find one single solution for everything. This was just done in a couple of hours and it's only the first iteration. Quick action button Next to the ProcessWire logo is the quick "Quick Actions" button. It should be possible, to configure it like: "Create a new Page with Template X with page Y as a parent". Use it for skyscrapers, news or galleries. (Yes i know, the arrow is pointing upwards. This is wrong) Two column layout The page tree is always visible (as long as we are in the pages view). It can be navigated as the normal page-tree. If you click "edit" it will become highlighted. Every action that would take you to a new page, would be displayed in the other half of the monitor. Speaking of a "half monitor" - I think that most people use a screen resolution of atleast 1300px. The sidebar should take up to 1/3 of this. On smaller screens, it will become hidden by default or we just simply step back to single pages for each view. If the content is to long, the sidebar becomes scrollable. Page tree I like the Template Decorator made by mindplay.dk. It fits the concept well with black outline icons for every type of template. The same icons could be used in the Quick action menu. I'm note sure what to do with the "move" action. To Do list Think more about the behavior of the elements. Design the modules view. Rework the search and the top menu. Options to "brand" the panel for agencies while keeping the ProcessWire logos. What happens if we are on mobile (small screen) devices? Listen to your feedback.
    1 point
  17. This is a very simple way to display some instructions to the admin users. Before starting, you need to write some docs; they can be a hidden branch of your page tree, using basic-page, or a different template of your choosing. You should make each subject it's own page under the docs so you can output each one under an accordion trigger. Required Module: Admin Custom Pages 1.) Follow all instructions to install the module; Also add the ACP_scripts_and_styles field to the admin template. 2.) Make a new page under admin, called Docs or whatever; assign the process as described in the module instructions. 3.) Make a template in your themes directory to generate the output of the docs page. 4.) Select that template from the page select in the admin custom page you created. 5.) also make a folder to keep your admin custom pages scripts and styles; 6.) create a css file to use for the display output and some basic styles (like ol, ul li etc..) 7.) Add the custom css file to your ACP_scripts_and_styles field. You can use any output you want, but i'm using a nested accordion, which is provided here: http://tympanus.net/codrops/2013/03/29/nested-accordion/ this is the content of the admin custom page: <?php $docs = $pages->get(4259); ?> <div id="docs"> <ul id="cbp-ntaccordion" class="cbp-ntaccordion"> <?php foreach($docs->children as $doc) { ?> <li> <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3> <div class="cbp-ntcontent"> <?php echo $doc->body;?> </div> </li> <?php } ?> </ul> </div> <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script> <script> $( function() { $( '#cbp-ntaccordion' ).cbpNTAccordion(); } ); </script> you'll also want to add the provided css, js and fonts that come with the Nested Accordion; in the css file you'll need to point the fonts to the actual font directory, for example: /site/templates/_admin_custom/fonts/icomoon_arrows/icomoon.eot it should come out looking something like this: *if you are using Reno theme, you can customize the icon, like for example fa-book, which is used in this example: -- Thanks & Credits to Diogo for originally creating the ACP module, and for Nico for getting it to work with the new admin theme system...
    1 point
  18. i knew that would come - but i only knew that things like this were possible: $a = $b = $c = "any value"; didn't know that it was possible to assign different values to different variables in one line. thank you! php.net reference @kathep great writeup indeed! more to come... have to restart my pc $content = "'" . $page->quote_text . "'". "—". $page->quote_author . "<br>" . "$page->quote_category"; https://processwire.com/talk/topic/8626-multiple-random-ads/?p=83345
    1 point
  19. Great writeup! Now that you have learned the full way to create the templates and pages for populating a page field you are qualified to do it the easy way http://modules.processwire.com/modules/process-page-field-select-creator/
    1 point
  20. @BernhardB: oh thanks! No problem to correct me if I do such nonsense. Ähm, maybe I need a syntax checking here in the forums editor,
    1 point
  21. Make the container page have certain template, e.g. 'container', that template then could only have title field, so nothing else could be added to that page. In your menu creation, don't create a link for pages with template=container. Or: https://processwire-recipes.com/recipes/quick-first-child-redirect/
    1 point
  22. Ok, so if the page field that you added to the user template is called allowed_pages, then this should work: if($user->allowed_pages->has($page)){ echo "true"; } else { echo "false"; } It is checking that the allowed_pages field for the current user ($user) contains (has) the current page ($page) in it's array of pages. By the way, rather than my initial suggestion of ASM Select, I would recommend: PageListSelectMultiple
    1 point
  23. Howdie Newbie - glad you could make it to here. Time has come to sell all your other webgenerators. From now one PW's Engine is going to turbo drive all your webwheels.
    1 point
  24. @z Thanks for getting back and glad you found the issue. I think you'll run into many problem with 32mb real quick so I don't think setting memory limit in modules is a good way as it belong to server configuration. ----------- Note about an update to 2.1.6 - Fixed issue with an unexpected "\n" char in a summary of a newly added module that caused and error with jQueryDataTables parsing the json. So I'm sure many will run into this issue once they hit refresh and haven't updated to 2.1.6 yet. But see and make an update of ModulesManager you'd need to hit refresh. - So not sure how this will play out. Damn "\n"! In case just manually update or use the core module manager.
    1 point
  25. Just wanted to let you guys know that I have submitted a PR to Ryan to fix this issue: https://github.com/ryancramerdesign/ProcessWire/pull/823 Along with this, I wanted to note somewhere (for now here, although I will probably write a PW SVG tutorial sometime soon) that if you want to embed SVGs into CkEditor RTE fields and be able to drag to resize them, you need to add the following to the "Extra Allowed Content" section on the Input tab of the field: img[alt,!src,width,height] This allows the img tags to have width and height attributes, which allows you to resize the image to a fixed number of pixels.
    1 point
×
×
  • Create New...