Jump to content

MilenKo

Members
  • Posts

    466
  • Joined

  • Last visited

Everything posted by MilenKo

  1. @Edison Will try that once I get back to my place in a bit as I decided to step back from the problem and then hit it with fresh power and some caffeine ? With the page->save approach all my dates were properly populated, so step one is completed, however when I echoed the date, it still does not change with the language switch. Starting to think that the issue might be caused by not adding the language packs or some field settings I've missed...
  2. @Edison - another error, but this time on the closing bracket
  3. @Edison The code returned an error: P.S. With a bit of more digging, I was able to populate the value of $page->creaded by inserting the following code to my news-inner template: <?php $page->of(false); // date_created is my custom DateTime field for storing the value // To avoid date changes every time I edit the page, a check if the field is empty is added if($page->date_created == '') $page->set('date_created', $page->created); $page->save(); ?> Now I will test for multilanguage support and if it works, will report back ?
  4. @Edison There are no stupid questions especially when someone is trying to help without knowing all the facts. Unfortunately, even though I have full access to my server, I can't check /etc/default/locale as I am on a Windows server using OSPanel as my webserver. To make my life easier and to learn something new, I've added a new field called: date_created and set it as DateTimeField. Now the only thing left is to figure it out how can I save the value of $page->created to that field and to test the translation there. As I've mentioned earlier, maybe the issue is that I did not install any of the language packs available but only created the languages and added my _strings.php for frontend translation. As the owner of the website would be a super user, he does not want to have his admin and modules translated. I've added this code to my template footer: /* turn of output formating so PW do not give an error when we change the value */ $page->of(false); $page->date_created = time(); /* save the date_created field */ $page->save('date_created'); /* turn on output formating so PW work as it should */ $page->of(true); but for some reason it does not want to populate the value of $page->created to the date_created field... P.S. Since I am working on a testing profile, I can mark the option "default to todays date" and it would start saving the date/time, however if this was a profile with hundreds of pages that should preserve their creation date then I will have to populate somehow the value of $page->created to my DateTime field..
  5. @Edison I echoed the setlocale and it does not change for the language showing this for all of them: LC_COLLATE=C;LC_CTYPE=English_United States.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C I just noticed that I have a lang="en" in my html opening tag. Could it be because of that?
  6. Hi Edison, I've tested your suggestion after removing the setlocale from my header.php and adding it to LanguageSupport.module C for every language. Echoing the $page->created shows the time properly, however when testing with echo strftime("%d %B %Y", $page->created); the date shows in English only no matter of the language. I sort of like more your idea of having a DateTimeField however not sure how can I set it to have the $page->created populated automatically in it so that I don't have to type it manually? Also, any ideas about what could be the reason that strftime works for you, but not on my side?
  7. Hey all. After having completted a dozen of profiles now under ProcessWire I've realized that I never had to translate a date due to the fact that I was working on personal profiles and I used numbers time format. Well this is changed now and I have a function to show the date of the page being created which I would need to translate based on the language selected: <?php echo date("F dS, Y", $page->created); ?> I've read several other posts where people had an issue with page date field and that was resolved, however how would I achieve a similar functionality without a field and just echoing the date in some format? Using the afore mentioned call works, however the month is not translated. Tried to use strftime function: <?php echo strftime("%d %B %Y", strtotime($page->created)); ?> and that returned '31 December 1969' Maybe it worth mentioning that I have 3 other languages besides the English set by default (Russian, French & Bulgarian), however I did not add the language packs as I only need the multilanguage part to work for the frontend. As per some suggestions, I've added the following code to my header.php: switch($user->language->name) { case 'default': setlocale (LC_ALL, 'C'); break; case 'french': setlocale(LC_ALL, 'fr_FR.utf8'); break; case 'bulgarian': setlocale (LC_ALL, 'bg_BG.utf8'); break; case 'russian': setlocale(LC_ALL, 'ru_RU.UTF-8'); break; } but the month names are still showing on the default language only. Tested to see if the setlocale is applied properly by echoing the language LC_All value and it showed promptly for every language. Where and what am I doing wrong is the million dollar question? ?
  8. @tpr Tell me about it ? Just because of the div opening markup I was crushing my head for some time before I "split" the selector in two and then applied the every foreach inside of every div ? This could all goe to the CSS but hey - different people, different taste ?
  9. Well I initially tried with the good old counter approach but things got messed up a bit because of the differences in the markup of large image post and others. Will revise the code and see how to include the opening and closing divs properly. Here is the markup I am working with: Where Large image post shows twice and List Item show 4 times ?
  10. Thanks @dragan will try your approach to see how would that fit, however it is not just styling but the markup is different where the first 2 news are required to have a large image with some intro text, author, date, likes etc. where the next 4 are just title and date of posting. That is why initially I thought to "slice" the array but it did not work properly so with $a->slice it did the trick. I will see how to serve the posts with a single foreach to avoid duplication, however the classes of divs are different, some javas are included in the no-image divs and some data handling. Not sure if I add a variable for the class, one for the javas and one for data- values to include in the div which one would be faster since I am looping once through 2 results and once through 4 others. Maybe I could try using modulus operator or other approach as well ?
  11. Hey @SamC I was looking for a way to style some results of a selector differently than others and found your 'slicing' suggestion fitting perfectly to my scenario. Here is a short example of what I have and would allow any results from to be styled one way and the rest - another: <?php // Check if there are any news added if (count($news->children)) { // Create am array with the latest 5 news $newsposts = $pages->find("template=news-inner, status=published, sort=-date, limit=6"); // Create a slice of 2 posts for the large image style // 0 means the starting record, 2 means the number of records to slice $left = $newsposts->slice(0,2); // Grab the rest of the posts from the list for styling with just a title and a date // 2 means that everything except the first two would be assigned. // The results limit is set initially at the selector $right = $newsposts->slice(2); } ?> Having done that, it allowed me to simply loop through the $left and $right results (using foreach) and apply the proper markup for first appearance and the rest. Using this elegant technique would allow to have as many slices for different styling if a need be. Unfortunately, my markup for the first news was in a row div that was closing before the rest of the posts appear in another row so I had to loop twice with foreach. I am sure there is a better way to include the opening and closing divs to avoid double/tripple etc. looping but as far as the result are not more than 6, I am not that worried about slowing the page down...
  12. @Edison Technically I do not need to show the comments of both languages but am just saying that someone might read the comments in one language but post to another if he is capable of etc. In such scenario you might end up having someone read your page in English but then writing the comment in French since he is more used to it or vice versa. Well in eather way I can live with it if a few comments listed are not with the same language. In theory my goal is not to complicate too much the things but simplify and I think I will be good with your suggested modification ?
  13. @Edison That is what I thought would be the idea behind it. The only issue that may arise is if an user is reading the website in one language but is posting the comment in another one just because he can. Great example would be bilingual countries like Canada and other parts of the world where English & French are official so if I am reading the website in French but post a comment in English, that would still show the comment to the French part. Of course not many cases of users doing that would be out there, just noting a possibility. If a user is logged on, maybe the language can be picked up from their user profile settings, however in cases where the users are allowed to post comments without a need/ability to be logged on, that would be impossible to pick. Not sure if with the power of PHP the language can be obtained from the OS settings by default but that is getting away from the purpose and might be a subject to GDPR and other regulations of privacy. In any way, will test your idea on the default profile and see how the functionality works. It is definitely a huge step forward towards multilanguage comments...
  14. I will test it on the startup language profile to see how it will work and will get back to you. How would PW get the language ID for the user and pick the comments? Here is a scenario I thought of - the default profile language is set to English but there are some other - Russian, French, Italian etc. So I am reading the website in Russian as it is more convenient for me, however I speak several languages and my comment is posted on French or Italian for example? Would the language get recognized, or the language ID would be picked up from the language I am reading the website on?
  15. Oh my God! I am working on a new profile of a multilanguage corporate website and was asked to add an ability to post comments under the website blog section. So I was checking up with Google to see how Wordpress and other CMS/CMF are completting the task and to my surprise, someone ( @Edison? )just posted a solution that should work in a similar way to my understanding of comments logic. Since FieldType Comments is not language oriented (yet ? ), initially I could have added an option to translate comments etc. however on a huge website this could be an overkil of work. So I thought that logically, if someone is switching the language from default to some other lang, the comments listed should be showing only in the language selected but not in the original/default profile language. Not sure how well your solution would work, but would definitely give it a try as I hope it is a much better solution than having multiple PW installations for every language in order to achieve the comments to be posted in the default profile laguage.
  16. After a few quick tests, I found it pretty straight forward to echo the content of text/textarea. In addition to the present functions of the module, it would be great if we could set the default state of the field (open, closed) as well as to have some logic of fields appearance based on other fields value (like it is with regular fields)
  17. @OLSA Hey man, I just found your amazing module while looking for an easy way to add a bunch of settings to a Profile Configuration page and I am trully impressed. I've seen some other great modules which I initially planned to use but to have a drag&drop functionality would make the development much easier for me (maybe I am too lazy). I am testing it now and will see how will it work. At least I can combine the file upload/image uplad default PW fields with the "custom field" of your module and avoid the need of adding image paths etc. Thank you for this masterpiece!
  18. Hey gents. I've been asking myself this question for quite a while now and even though I've completed some projects purely and entirely out of PW core + free modules, I've been always envy of the simplicity in code and to minimize the database/website load. As it appears, in times when I had to revise some of the profiles code I was finding a better and simpler approach based on some shared recent or good old (but not forgotten) tricks by all the smart persons presenting this amazing ProcessWire community. The more I analyze the code, the more strong need I feel to get the ProFields module for several reasons: a.) All the advice and help that have lead me to my present skills were kindly given absolutely for free with no questions asked and no matter if the answer was helping me generate some revenue. I am 100% convinced that I "owe" back to the community and its major developers the support (my 5 cents back ? ) b.) Being a bit selfish - I would really like to spend less time on a project while still delivering the same if not much better and simpler solutions. To achieve all this, I would need the tools kindly included in the "ProcessWire toolbox" called ProFields. Initially my plan was to build a few profiles, generate some revenue and then spend some of the finance to purchase the tools needed, however most of the profiles I've built were for personal or close friends/relatives from which I did not generate much out of respect. But I've learned that with the proper tools, even when I am "working for pennies" I can complete the project faster/easier and move on to the next of kind. c.) As it was previously mentioned, everybody is in a need of a stable financial position as otherwise no matter how good is the will, everything seems to be doomed to an end of a failure. By buying the ProFields module, I would not only support the respectful development team, but also the community itself as the new releases, modules, tweaks etc. would keep on going. To me - this seems like a healthy recipe of success. d.) Not sure about others, but at least in Canada I am allowed to claim some work related expenses while working as a self employed, so I have a choice to either give/share my money with the developers team or to give them to the government in the form of taxes. Well, let's just say I got tired of paying taxes ? e.) The words: "free for life" or "use on as many websites you want" got me by surprise. Most of the platforms I am aware of are selling their licenses per user, per device, per website etc. but I have not seen a single one stating that I can use a bunch of modules to sell websites etc. and that can go on and on to as many users as I can convince of my skills. I have some pre-sale questions, but I am sure that everything is as well covered as it is with all the freebies so I will not pose some, wait for answers and waste more time on this. I am about to start working on a new project where I clearly stated that without the tools I need, I won't be participating so I am very much eager to start "playing" soon with all the masterpieces included in ProFields. I just wish that the price was in Canadian dollars or at least I've bought the license at the time when CAD to US was 1.04 to 1, but hey - it is an economy driven situation so there is no one to blame on this other than myself waiting for so long.
  19. Hello all. I just found about the existence of this module after a few built profiles with a custom settings page and some extra fields added to it to maintain logos, texts etc. I must admit that this seems much more clean to me and would be definitely testing it in my next personal project where I won't care if a user would accidentally add/delete something as I will be the one to administer what I've built. I see that the module has an ability to add a FieldSet Open/close , however would there be an easy way to add FieldSet Tabs? This way we could group specific options and separate them to a tab? Edit: I just read an earlier comment of mine about testing this module or @Macrura fork of it so I must have forgot about it with the time ?
  20. Well you have thought of it all. Great work, keep it up ?
  21. I see, but at your admin on the video in Design tab you have over 15 fields not counting Fieldset in tab (open/close) (for the design) and Fieldset (open/close) for Basic, Text align, margin, padding. It is a similar scenario with me and that is why I am trying to reduce the number of fields. I know with ProFields I could reduce them a lot, but not yet there financially.
  22. Nice work joer80. Looks great. I am wondering though, how many fields would you count in your profile as only the Tab_open takes two per section so unless you use some tricks, you might end up with a huge fields list? Btw, after completting my two category blocks with all the bells and wistles I realized that instead of using one tab_category attribute and set its type to asmselect I used 10 fields (tab_category_1, 2, etc.) which caused me some troubles to check the array for empty values, then sort them out etc. I am working on redoing the markup which would simplify a lot the code and would be much easier to "digest" and re-purpose. ProcessWire keeps amazing me every single day with the freedom of code, approaches, functionality OOB etc. It really applies to the saying: Sky is the limit!
  23. So after playing a bit here and there, I came up with a simple structure that would hold the following blocks: Header style, Slider style, upper/middle/lower main section, upper/lower sidebar section and a footer one. One of the header styles markups allows for a header banner so I set the field with Select options and added a condition when to show the code field that would hold the banner (header_style=1). The slider has been set the same way with six different styles using Select option but the seventh option allows for no slider at all. For the main area blocks, I will be using Hanna Code in combination with Dialogue where I have some attributes for different blocks representation (category, number of posts, field descriptions/notes etc.). This allows the blocks to be re-organized in a preferred way as well as to repeat or swap blocks from zone to zone. The main block and sidebar are split by a full-width section where I can add a large banner and any other larger blocks to present some content. For the footer - nothing much to say - the same approach as for the main area. Sidebar - same thing as the footer and main area - HC & Dialogue. Like I said, nothing special here, but it is easy to configure and modify if a need be.
  24. I was looking today at the PRO FIELDS MODULE and it seems to be the perfect fit in many occasions to complete a very easy to administer page builder, however that would require some investment to make. Quite honestly, if anyone is determined to use ProcessWire as a developer, the module cost would worth every penny and if I understood correctly, it would allow an unlimited number of websites to be used on. This is like a developers edition for Process Cache etc. I guess I will complete my profile using standard fields in combination with Hanna Code and Hanna Dialogue (using some attributes for selectors) but later on I will switch to PRO once I get the finance sorted out ? Presently I've almost completted the blocks structuring so it is just a matter of time and efforts to build the blocks for every section and move on. Will post some screenshots/info once ready.
  25. Never mind. It was after all the modified version of the FieldTypeComments module where the class was defined. It was a painless process where all I had to do was to copy my CommentForm.php, CommentList.php and comments.css to have everything back to normal and the new functionality in place.
×
×
  • Create New...