Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/04/2018 in all areas

  1. Interesting blog post on the sharp looking site of Internet Dreams (via the latest issue of weekly.pw) https://www.netdreams.co.uk/blog/processwire-website-development/
    4 points
  2. This (and selecting by id) seems to be the best answers for my question! Thank you @Zeka and all others for your help! I've heard before that the Processwire community is very helpful and friendly and I have to say that's absolutely true! I'm just trying to understand the basics of Processwire. Hence my seemingly pointless questions. I come from a different CMS (MODX) and it's a bit difficult to rethink at first. So I hope you'll also excuse my upcoming stupid questions... ? @bernhard Hey, I'm also from Austria - only 60 km from Vienna, in Mattersburg.
    3 points
  3. Everybody can make music. ? https://audiotool.com is a powerful pretty unique in the browser sound production studio. I remember back then it was made with flash, nowadays it's a JS app with 600k lines of code. Pretty amazing if you never seen it try it out.
    2 points
  4. Awesome to see that, need to look at that library as I've never heard about it... I've built a function to get data instantly very easily - have a look at the pluck() function in RockGridItem.js; It works similar to jQuery Datatables library that I've used before. And I found getting data there quite easier than with aggrid. That's why I built a similar replacement. See this example where I can select selected or filtered items: // get items var rockmailer_to = $('input[name=rockmailer_to]:checked').val(); var items; var testmail = false; if(rockmailer_to == 'selected') items = grid.pluck('id', {selected: true}); else if(rockmailer_to == 'filtered') items = grid.pluck('id', {filter: true}); else { // custom test address var testmail = $('#Inputfield_rockmailer_test').val(); if(!testmail) { ProcessWire.alert('You need to specify a Test-Mail-Address!'); return; } items = [testmail]; testmail = true; } if(!items.length) ProcessWire.alert('No items selected/filtered'); Wow @Beluga just had a look at apex charts and that looks fantastic! I was short before creating a module for chartjs but then quite a lot of client work popped in... I'd be very happy to assist you in creating a charting module that plays well together with RockGrid, so if you are interested please drop me a line via PM ?
    2 points
  5. I need to send E-Mails with embedded images. Therefore the image urls need to be absolute httpUrls instead of relative ones like /site/assets/...; I didn't find one, so I created this: <?php namespace ProcessWire; /** * Converts relative CKEditor image urls to httpUrls * eg /site/assets/files/123/demo.png * to https://www.demo.com/site/assets/files/123/demo.png */ class TextformatterImagesHttpUrl extends Textformatter { public static function getModuleInfo() { return array( 'title' => 'Relative Image Urls to HttpUrls', 'version' => '1.0.0', 'summary' => "Converts relative CKEditor image urls to httpUrls.", ); } public function format(&$str) { $url = $this->wire->config->urls->files; $httpUrl = $this->wire->pages->get(1)->httpUrl; $httpUrl .= ltrim($url, "/"); $url = str_replace("/", "\/", $url); $str = preg_replace("/src=\"$url/m", "src=\"$httpUrl", $str); } }
    2 points
  6. @Gadgetto There is no problem with getting pages with the name field. Just use default language value as selector value. Getting page by name has some pitfalls, $pages->get() return the first found page, but you can have several pages with the same name under different parents, so you should specify parent selector to make sure that you are looking for the needed page. So basically you can use this in English and Deutsch languages d($lang->title); // english d($pages->get("name=sample-page")->title); // Sample page $user->language = $languages->get('deutsch'); // change user language to deutsch d($pages->get("name=sample-page")->title); // beispiel-seite But if you want to find your page by Deutsch name: $lang = $languages->get('deutsch'); get deutsch language d($lang->title); // deutsch d($user->language->title); // english d($pages->get("name{$lang}=beispiel-seite")->title); // beispiel-seite
    2 points
  7. I have to support the existing anwers. It totally depends on you what the best option for selecting the page is. And the most important part of that question is WHY you want to select this page... Is the page a settings page? Then it might be the best to select it via ID (changing names to not break your code) Is the page part of some listing (eg list all news items on the news overview page --> select it via children/parent or via template, eg $pages->children(), $pages->find('template=newsitem'); Many other scenarios, so your explanation is a bit too general imho ?
    2 points
  8. You can do it multiple ways and that really depends on you! I will assume for now, that sidebar content wants to bring in some info from the articles section of your website. Lets say you get the idea to use the structure of the page tree to organise content and make it easy to get those articles to show on home page. So, you could pull something like this to get ten articles which are identified with the template "article" (that has title and summary fields!): $pages->find("template=article, limit=10"); Another way, could be to get all pages, whose parent has the template articles (for convenience, this template is used once throughout the whole site, to handle this parent page): $pages->find("parent.template=articles, limit=10") And another one to ask for the first page found with the template articles, and then get the first 10 children: $pages->get("template=articles")->children("limit=10"); Which is the best? It's your call! Will depend on a lot of things, just to give an example, on the last option to get the articles, I am assuming all pages under Articles, are actually articles. What if a page that is not an article exists under there?? Maybe something like:
    2 points
  9. @Gadgetto What do you mean with 'select a page'? Does this section answer your question? https://processwire.com/api/multi-language-support/multi-language-fields/#how-language-fields-work
    2 points
  10. @Gadgetto foreach ($languages as $language) { ... $hreflang = $page->getLanguageValue($language, 'languagecode'); // ... } As you wrote, you have added 'languagecode' field to language template, but in your snippet, you are trying to get value from 'languagecode' field from $page which, I assume, is using home or basic-page template. This code will work if you add 'languagecode' field to a template which used by the current page.
    2 points
  11. This week, ProcessWire 3.0.118 contains several updates and this post covers them all. The most significant update is a useful new addition for viewing and manipulating page redirects, right from the page editor: https://processwire.com/blog/posts/processwire-3.0.118-core-updates/
    1 point
  12. I am using ApexCharts.js, which is kind of a spiritual successor to Chartist.js in that they both produce SVG charts. I am experimenting with what is possible, trying to figure out visualisations of the data that would be useful and attractive. Here is a screenshot of ApexCharts playing together in real time with RockGrid filtering (edit: nevermind the incorrect/repeating data labels, I only noticed and corrected later): We see a stacked bar chart representation of the number of literature references per filtered proverb type. I intend to split the thing into separate charts for each of the 13 top level categories (ApexCharts unfortunately does not support multiple series of stacked bars in a single chart). This will make it readable even with the unfiltered view of all 325 proverb types. It was quite convoluted to get the libraries to play together - grid.gridOptions.api.getModel().rootNode.childrenAfterFilter did not want to yield its contents, but guarded it like a jealous dragon. To get access to the data, I had to brute-force dispatch an input event like so: var inputTarget = document.querySelector('.ag-floating-filter-full-body:first-child input'); var inputEvent = new Event('input', {'bubbles': true, 'cancelable': true}); // have to use delta timing to delay the input event - in // case of big existing CPU load, it will fire too soon! var start = new Date().getTime(); setTimeout(function() { var now = new Date().getTime(), delta = now-start; inputTarget.dispatchEvent(inputEvent); },500); Then, to initialise the Apex chart in proper order, I had to wrap its stuff into a function. I called the function from my afterFilter: function afterFilter(grid) { var filterKids = grid.gridOptions.api.getModel().rootNode.childrenAfterFilter; var mapCodes = filterKids.map(x => x.data.code); var countedCodes = mapCodes.reduce((r,k)=>{r[k]=1+r[k]||1;return r},{}); apexseries = Object.entries(countedCodes).map(([p, v]) => ({'name':p, 'data':[v]})); var apexdiv = document.querySelector("#chart"); if(!apexdiv.hasChildNodes()) { apexi(); } else { ApexCharts.exec('proverbs', 'updateSeries', apexseries); } }
    1 point
  13. Hi Francesco, Yes you can do this in Processwire. This is not part of Processwire but simply part of javascript and css. Here is some basic use of javascript and css to achieve this: <script language="JavaScript"> function setVisibility(id, visibility) { document.getElementById(id).style.display = visibility; } </script> And here is an example to open a little window like you mentioned: <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("window-child.html","Ratting","width=550,height=170,0,status=0,");> Click here to open the child window </a> Here is a small tutorial that shows you how you can open a little window: https://www.plus2net.com/javascript_tutorial/window-parent.php Instead of opening a small window you can also toggle hiding and showing your own div inside Processwire, in the example below you can replace the button with a word as you mentioned: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_hide_show
    1 point
  14. Thanks for the free support ? I got it working with the syntax grid.gridOptions.api.addEventListener('filterChanged', function() { afterFilter() }); This allows me to pass the grid object to afterFilter and then do interesting stuff with grid.gridOptions.api.getModel().rootNode.childrenAfterFilter I am going to mess around with dynamic charting!!
    1 point
  15. Sorry, I can't provide free support here for such specific problems atm. You might try to search the repository for "filterchanged" and see how I use it in different occations,
    1 point
  16. Ok. First of all, make sure that you know how selector works in PW. https://processwire.com/api/selectors/ You can get a page by its id: $some_page = $pages->get(2030); // get page by id echo $some_page->title; echo $some_page->summury;
    1 point
  17. Thats the same what I said in multiple posts here. You don't have to see the words "best answer" anywhere. Some other Q&A style forums use the words "Accepted answer". I would not like a list of "solutions" under the first post, because there could be many (think Support forums), and the "solutions" could be evolved through further discussion, that might be different to the initial question. A button/link "Most useful or upvoted replies" would be difficult to implement, because it makes no sense in support forums, and even for Q&A style forums, the list could be long, and what would be displayed? The last x replies with the most votes? Please note that I use the word reply instead of answer now. Because not all replies are answers. I think that changing the wording and thinking of replies instead of answer/s helps a lot in this discussion. Yeah, thats why the poster can decide which is his preferred "accepted or most useful reply". We have to disctint between two types of forums: Q&A and support forums. In the support forums the OP would not mark a reply as "accepted reply" because it was no question he had asked. I hope that makes sense because you have to think a little different to how the forum software works right now. One problem is, that if you change all forums to Q&A style the flow of the conversation is ruined as @Pete stated. Maybe there could be a plugin for keeping the sort order chronologically, without pulling the most upvoted or accepted reply out of the flow? The other problem is that in normal forums we can not up- or downvote replies.
    1 point
  18. You can enable / disable it in the page editor on the settings tab. There is a checkbox for each additional language near the inputfield for the language page name: If you want to check / debug this in your template file(s) for some roles or users, you may add a code snippet like the following: $languageWarning = ''; if(($user->isSuperuser() || $user->hasRole('NAME_OF_YOUR_EDITOR_ROLE')) && '1' != $page->status1063) { // active checkbox is not ticked! // italien language is disabled !! $languageWarning = "<div style='text-align:center; margin:0; padding:0; min-height:30px; background-color:#EEFFEE; color:red;'> !! WARNING: Content for Italian Language is disabled !! <br /> Go to the settings tab in the editpage and check the box to activate it, if this is by mistake. </div>\n"; } // change the number from status1063 to that from your language id, or you may derive it programatically from the languages object In the page markup I output the content of $languageWarning, what only can have content for certain roles or users. Thus the output can stay in markup of production site templates with no harm.
    1 point
  19. You need to check the rights for the laguages currently not shown to guests. The language in general and on a per page base, I believe. (Currently on mobile, will provide a jpeg when back in office)
    1 point
  20. Hi Guys, I am currently testing the Login/Registration Front End Module. https://modules.processwire.com/modules/login-register/ I see it only supports standard fields and not image fields. I wanted to give the ability to a user to add a profile pic and one more image field that will most likely be used for a background image. I have built something like this strictly using the API and PHP inside of templates. Any light on accomplishing this by modifying the module? Thanks.
    1 point
  21. At least I don't say no regarding that idea. ? But moving that framework in to a module should be the goal in any case. Currently its more a grown bunch of functions which urgently needs some maintenance to split my ~1500 lines of code in _func.php into something self documented. This has to happen in a near timeframe anyway and creating a module from the core functionality doesn't seem to be too much work on top. To make this public, I probably first need to get rid of the (great!) Form Builder module, which is kind of overkill anyway but simplified playing around with CKEditor configurations and field layout a lot. Will check next months, can't promise anything yet.
    1 point
  22. @gebeer It looks like you got further into the solution than I did. Tabs and repeaters were a problem for the Profile Edit screen for me, too. So I eventually gave up and gave users of that template type a role that gave them page-edit permissions, but I hadn't worked out how to make sure that people were only editing their own profiles - so I think your two hooks are helpful there! I know there's a difference in form and function for Profile Edit and Page Edit, but our scenario (where Users = Content) seems like a time when keeping the two completely separate breaks down. I think your method is clean and I will give implementation a shot. Thank you!! Edit: Just saw you'd posted twice in this thread, and just now read the first: That. Exactly that. In full! If it's on a profile page, and I've given the user the permission to edit their page...they should be able to do whatever is necessary on it.
    1 point
×
×
  • Create New...