Jump to content

Valery

Members
  • Posts

    121
  • Joined

  • Last visited

  • Days Won

    1

Valery last won the day on May 8 2014

Valery had the most liked content!

Profile Information

  • Gender
    Male
  • Location
    Saint-Petersburg, Russia

Recent Profile Visitors

6,200 profile views

Valery's Achievements

Sr. Member

Sr. Member (5/6)

90

Reputation

2

Community Answers

  1. Thank you, Robin S! That was exactly what I was looking for ?
  2. Hello everybody! One of my clients seems to be using the extra page actions a lot, and he is rather that they are visible to him without clicking the "extras" icon (">") to expand. So I decided I'd throw a couple of hooks to add some extra page actions to the regular page actions, so that they become instantly accessible without the need to expand the extras. Here's a fragment of code from my /site/ready.php I was trying to use a global variable to store the extra actions array but I don't seem to be able to use it in the second hook. /* * A couple of hooks to add page action * "unpub" to the list of non-ajax page actions * alongside with "new", "edit" etc * */ wire()->addHookAfter("ProcessPageListActions::getExtraActions", function($event) { global $extraActions; $extraActions = $event->return; }); wire()->addHookAfter("ProcessPageListActions::getActions", function($event) { $actions = $event->return; global $extraActions; $actions['unpub'] = $extraActions['unpub']; $event->return = $actions; }); Somehow var_dump(extraActions) keeps giving me a NULL. I don't really think I should develop a whole module just to change the list of page actions; I just need the extras to be immediately visible without the click. Could you please help me out? Any hints or solutions are more than welcome!
  3. Hey there! While not a part of PW, you might want to check out htmLawed, an advanced HTML filter/purifier.
  4. Hi! Will "Show this field only if" condition work for you? You could specify an id of a page on which you would like your field to be present. I am attaching a screenshot to illustrate my point.
  5. Hello! I've been migrating a Joomla site to PW. As I was at it, I could not help notice that the text of the articles I was importing into PW was messy. The site owner confessed that he simply pasted his text from MS Word into Joomla's editor, which resulted in very dirty HTML full of inline CSS and custom class names. So this got me thinking of tools I could use to clean this dirty HTML. After some search I stumbled across a handy PHP tool named htmLawed developed by Santosh Patnaik. What I liked about htmLawed was its flexibility in filtering and cleaning HTML. My goal was to strip off the style attributes from <p>'s in my HTML, which was way below htmLawed's capabilities. It can do a lot more -- reading the list of features got me hooked up! The htmLawed download contains just two files: the software itself, and a script to measure performance. Including htmLawed in a PW template is a matter of one include(), and after that you are ready to go. Using any HTML formatter adds a certain memory footprint, so using htmLawed for outputting each and every piece of HTML might not be the best idea; but nevertheless it's a handy and flexible tool for sanitizing and beautifying any HTML before saving it in your PW page. htmLawed is free, well-documented and flexible. Give it a try if you feel you need more control over HTML that your users post. http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/
  6. Hi everybody! I am migrating a Joomla site and I am having troubles with Joomla's URLs. Joomla links look like this: www.example.com/index.php?option=com_content&view=article&id=80 I have set up my prependTemplateFile to detect GET variables that Joomla uses, and redirect to PW pages: // Example: index.php?option=com_content&view=article&id=80 if ($input->get('option') && $input->get('id')) { $j_article_id = $input->get->int('id'); $target = $pages->findOne("j_migration_id=$j_article_id"); // `j_migration_id` is the field where Joomla IDs are stored if ($target->id != 0) { $session->redirect($target->url()); } else { $session->redirect($target->url()); } } The problem I am having is this: the above code works fine with any template but home.php But when a Joomla URL is called from the root of the site, PW simply redirects to the root page. For instance, www.example.com/index.php?option=com_content&view=article&id=80 redirects me to www.example.com While www.example.com/some-page-with-custom-template/index.php?option=com_content&view=article&id=80 does what expected: redirects to the right page (e.g. www.example.com/some-page-with-custom-template/some-page/) The question is: does either the root page or the home template have there any exceptions for GET variables processing?
  7. Hello Michael, In response to your earlier post: I've tried storing PageTable pages directly under the parent but it didn't work (for me, at least). However, the idea behind trying to use existing pages in a PageTable field escapes me. Why not use Page fields with PageListSelect+ instead? For instance, here is a screenshot of mock-up of a color chooser for a webshop item.
  8. Hi verdeandrea, and thanks for a chance to think it over. Why not have a template for Teachers where their names and emails would go, and another template with page fields which would display teachers' names and emails on your Course page? I did a mock-up quickie. If you are curious as to how it might look, I've attached a couple of screenshots.
  9. Excuse me for interrupting, but what PW version did you find this option for a PageTable field? I am using 2.5.3 and I see nothing like an "add an existing page" toggle for a PageTable field.
  10. Hi, Just my 5 cents. Give Closure Compiler Service a try. It is good at removing "dead" code, i.e. the functions of your libraries/frameworks that are not used in your JS code.
  11. Hello, You might want to look at HAProxy. Here's a nice article on using it. https://www.digitalocean.com/community/tutorials/how-to-use-haproxy-to-set-up-mysql-load-balancing--3 And this is an article on how to set up master-master Mysql replication. https://www.digitalocean.com/community/tutorials/how-to-set-up-mysql-master-master-replication
  12. Hello, PageTable is described as a leaner way to enter large amount of repeatable data into the admin backend, possibly with different sets of fields (think different templates). The main advantages compared to the Repeater are: 1. PageTable can save new pages where you tell it to. Repeaters are saved deep down the Admin pages and are given cryptic names. 2. One PageTable field can make use of several different templates. Repeaters play according to the "One repeater = one template" rule (roughly put). PageTable is a PageArray, so relevant methods are applicable. For example, here is how to add and remove items from a PageTable field using the PW API: // create a new page // IMPORTANT: your PageTable field must be configured to use template 'basic-page' in the field Setup tab $newpage = $pages->add('basic-page', '/about/', 'address', array('title' => 'Write to us')); $page->of(false); // add the newly created page to 'pt' which is a PageTable field $page->pt->add($newpage); $page->save(); Here is how to remove the first item from a PageTable field: $page->of(false); // 'pt' is a field of type PageTable $page->pt->get(0)->delete(); $page->save(); That's a quick overview of this new field type. Give it a bit of your attention, it's quite promising. Cheers, Valery.
  13. Thanks, adrian, really appreciate your help. Yes, it started to work and I saw the 'custom' page action. The problem is, it now affects all instances of ProcessPageList, including /processwire/page/edit Thanks, though. I will see what I can do.
  14. Hello adrian, I am sorry to say but this code does not work on my environment. Here is what I have in my module: public function init () { parent::init(); wire()->addHookAfter("ProcessPageListRender::getPageActions", function($event) { // anonymous function $event->replace = true; $new_action = array ( 'cn' => 'custom', 'name' => 'Custom', 'url' => '/my/path' ); $event->return = $new_action; }); } public function ___execute () { return wire('modules')->get("ProcessPageList")->execute(); } The list of page actions that I receive in the output is not changed. I tried different browsers, did a reset & flushed cache. I sense that the "ProcessPageListRender::getPageActions" hook is somehow not working for me. If so, what could be the reason?
  15. Valery

    Fooled isit.pw

    Hey guys, Please, please read netcarver's warning before making changes to the 'admin' template settings. Changing access for non-logged in users from login prompt to http 404 may effectively block you from logging in! If you have locked yourself out (like I just did), do the following: - Log in to phpMyAdmin. - Find the 'pages' table, then Browse it and find the Id of the page named 'login'. Mine was 23 and I did not change the default settings. - Then go to the table 'templates', find the line with name=admin and edit it. Add , "redirectLogin":23 to the array (assuming that 23 is the id of the login page). Save (press "Go"). Now you will be able to access your admin login prompt. I attach a screenshot, so that should be pretty clear.
×
×
  • Create New...