Jump to content

titanium

Members
  • Posts

    161
  • Joined

  • Last visited

Posts posted by titanium

  1. Has someone used this in combination with PW 3.0.8?

    I've installed it (like in PW 2), set the installed language in my profile, logged out / in, deleted the cache – but no translation anywhere :-/

    Works for me as well... As always, I simply added the files to the default language.

    Thanks for your continuous efforts, Manfred!  :-)

  2. Just tested your code under PW 2.7 and 3, I can't get it working on both version with the line $session->redirect(basename(__FILE__));

    Commenting the line, it show the integer (value 1) on both version.

    Thanks for testing!

    If you comment the line, than value 1 is shown. The difference is only visible after the redirect. May I ask you to try again with:

    $session->redirect('./test.php');

    given the file is named "test.php". I did edit my version above.

  3. (I already posted this in ProcessWire's issue list at github a week ago, but I'm not too sure if this really is an issue I should Ryan bother with. I hope it can be better answered/discussed by the community).

    I would like to collect form data in a session and do a redirect afterwards. After the redirect happens, I would like to read the form data back from the session. This follows the concept of the PRG-Pattern, which I consider as a good practice to avoid duplicate form submissions.

    In 2.7.2, the following code worked flawlessly. In 3.0.8, I can't get it to work anymore.

    Here's my simple test case (save it as "test.php", in parallel to the index.php). I hope somebody can give me a hint what's wrong with it.

    <?php
    
    include './index.php';
    
    if ($input->post->submit) {
        $session->input = $input;
        $session->redirect('./test.php');
    }
    
    if ($session->input && $session->input->post) {
        // 2.7.2: echoes "1"
        // 3.0.7: echoes nothing!
        foreach ($session->input->post as $value) {
            echo $value;
        }
        $session->remove('input');
    }
    
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    
    <form action="" method="post">
        <button type="submit" name="submit" value="1">send</button>
    </form>
    
    </body>
    </html>
  4. I think it's a matter of how you are going to output the repeater's contents. One possibility: add a date field to the repeater's items. If this date has reached, the item is not displayed anymore. Some untested code:

    <?php
    
    $home = $pages->get('template=homepage');
    
    if (count($home->myRepeater)) {
        foreach ($home->myRepeater as $concert) {
            if ($concert->date < time()) {
                continue;
            }
            // output any other concert information from here on
        }
    } else {
        echo 'Sorry, no concerts, pal.';
    }
    

    Another idea: You could check if the page to which the repeater links to (I suppose via page field) is still published. Some code:

    <?php
    
    $home = $pages->get('template=homepage');
    
    if (count($home->myRepeater)) {
        foreach ($home->myRepeater as $concert) {
            $concert_page = $concert->link;
            if ($concert_page->id && $concert_page->is(Page::statusUnpublished)) {
                continue;
            }
            // output any other concert information from here on
        }
    } else {
        echo 'Sorry, no concerts, pal.';
    }
    

    I hope I did get you right and the above code works and is of any help for you. Had no time to set it up and test it out properly.

  5. It would be very helpful to be able to log what method calls, file includes, new objects etc. ProcessWire uses when it does it's magic in the backend. Optimistic approach, granted, but I imagine this could be a way to re-use ProcessWire's backend processes more easily. This could help to automate the task I described in my last posting above.

    I'm not too sure, but in a small corner of my brain I remember that some kind of "macro recorder" module for ProcessWire does exist somewhere? Or maybe I just dreamt of this :-)

  6. Hi,

    I'm trying to automate the process of updating installed language packs with the help of the API, because I have to update quite a lot of ProcessWire installations and I would like to avoid these tedious tasks.

    While is easy to select the language page and upload the new language files to the field, I noticed that there is more to be done: Obviously the process of parsing the language files has to be started somehow. I looked around in /wire/modules/LanguageSupport and, well, I have to say that this seems to be above my capabilities. :-/

    Has anyone experiences how language files could be fully imported by API?

    Thank you.

    • Like 2
  7. Well, it's a web service. You can use JSON. Or some server driven mechanism, like curl and some php. It's the only external interface to ProcessWire as far as I know. Since you can't simply include ProcessWire in Typo3, I think it's the route to take...

    • Like 1
  8. No, you don't have to avoid using a variable called $options, because it $options is only used in a local scope, in this example it's used in the local scope of the method "renderPage()". It's not a global ProcessWire API variable like $page, $pages or $config, for example - you should avoid redeclaring these. Read more about these API variables here.

  9. I have done something like this half a year ago. I made an intranet for a company with 200 employees. There are no problems I heard of so far. It has a full text search, a searchable image repository with thousands of photos, every user has his own profile with his portrait... Most important thing was: every download of this intranet (PDF, Word, Excel, image files and so on...) is a page. I have build a  small multi file importer which allows to upload many files at once, which leads to creation of the according amount of pages with these files attached. I did this to give each file more properties (think of it as an" asset management" - every file can have properties like view rights,  tags, relations, descriptions, authors etc.). To assign this download pages to their parent "content pages" (the page the visitor sees in frontend view) I did use page tables very much. I think it works very good and I enjoyed it to develop and customize.

    • Like 6
  10. Hi all,

    I need to loop over several images with an ordinary foreach - nothing fancy. However, each image needs to have a unique css class name attached.

    The css class name needs to be unique? And you want to enter it in the backend by yourself somehow? I think this does not scale, because sooner or later you will use the same css class name twice. If it should be truly unique, I suggest a combination of $page->id and $image->name ($page which contains $image). May I ask why it has to be unique?

  11. Hi folks,

    I am using the PageField to find selectable pages and I'm using the 'custom PHP code' field to find my pages.

    However, the following isn't bringing back any pages:

    $pages->find('parent=/tags/' . $page->parent->name . '/');

    I have tested this code on the page template, and it returns the correct pages but entering this into the custom PHP field returns an empty dropdown field.

    Any thoughts?

    Did you try to write "return " ahead of the above command like this:

    return $pages->find('parent=/tags/' . $page->parent->name . '/');

    ?

    • Like 2
  12. I have tried adding disallowedContent: *[style]

    It's not possible to filter style as an attribute in CKEditor this way. CKEditor works with this pattern: [attributes]{styles}(classes). Valid attributes are align or onclick for example, but style is handled with the second part of the pattern, in curly brackets. What you can do for example: [*]{width} will strip style="width:10px" from all elements. You can enhance this functionality with own JS functions. Read more about it in CKEditor docs

    • Like 1
  13. Hi,

    I have a client which has a PageTable with a long list of PageTable entries. He feels annoyed that he has to scroll down the whole list in order to see the "Add" buttons at the bottom of the list. I would like to build a module which adds a second set of "Add" buttons at the top of the PageTable. I took a look at InputfieldPageTable.module and can see that the buttons get added in the function "___render" at line 117:

    		// render the 'Add New' buttons for each template
    		$btn = '';
    		foreach($this->rowTemplates as $template) { 
    			$button = $this->wire('modules')->get('InputfieldButton'); 
    			$button->icon = 'plus-circle';
    			$button->value = count($this->rowTemplates) == 1 ? $this->_x('Add New', 'button') : $template->getLabel(); 
    	
    			$url = $this->wire('config')->urls->admin . "page/add/?modal=1&template_id=$template->id&parent_id=$parentID";
    			if($this->nameFormat) $url .= "&name_format=" . $this->wire('sanitizer')->entities($this->nameFormat);
    			$btn .= "<span class='InputfieldPageTableAdd' data-url='$url'>" . $button->render() . "</span>";
    		}
    		$out .= "<div class='InputfieldPageTableButtons ui-helper-clearfix'>$btn</div>";
    

    Since there is no hookable method for adding the buttons alone, I think that there are two routes to take now:

    - Replace the whole ___render() method

    or

    - call the existing render method and parse the $event->return for css class "class='InputfieldPageTableButtons" and copy it on top of $event->return (DOM manipulation)

    Both ways feel clumsy and not future-proof in case of PageTable module upgrades.

    Is there a better route I should take?

    • Like 1
  14. 1. I'm wondering if it's possible to redirect the children of the site to the parent-site or to the homepage, when a user tries to visit the childpage directly, so that it's not possible to visit the child-page directly.

    2. How are the child-pages sorted? When I try to sort them via drag&drop here:

    1. Something like this should work:

    if($page->url ===  $_SERVER['REQUEST_URI']) {
    	$session->redirect($page->parent->url);
    }
    

    2. How are the child-pages sorted? When I try to sort them via drag&drop here:

    2. From https://processwire.com/api/selectors/

    foreach($page->children('sort=sort') as $child) {
    	require($child->template .'.php');
    };
    
  15. All the other attributes (including id) are either allowed in any form or not.

    I would like to add that this is true for allowed content rules in string format. If object definitions are used, there are more possibilities. For example, a function can be called which allows only a match of certain values for id.

  16. Thanks for this module, justb3a, it comes right just in time for me :-)

    However, I think there is a problem: I noticed that values for "caption", orientation or custom fields are saved in database (that part works). But if I edit the same image again, the values have disappeared. The fields are empty. If the image is saved again, the values in the database get lost.

    UPDATE: I tried to debug it. If I change line 1045:

    $value = $this->wire('sanitizer')->entities($pagefile->{$current}($language));

    to

    $value = $this->wire('sanitizer')->entities($pagefile->{$current});

    the problem disappears. I guess this fix does not work if you have more than one language defined.

  17. I'm trying to use this module to convert a bunch of png files to jpg. It works fine with a handful of images, but then it get's slower and slower. Here is my testing code:

    $images = $page->images;
    
    if ($images) {
    	foreach ($images as $image) {
    		$jpg = $image->pimLoad()->setOutputFormat('jpg')->pimSave();
    	}
    }
    

    And here are the debug times in seconds - every number at the beginning of the line shows the loop count (it equals the number of images converted):

    1: 0.21
    2: 0.41
    3: 0.67
    4: 1.08
    5: 1.96
    6: 4.42
    7: 12.79
    

    In fact it's always the same image with a different name (1.png, 2.png and so on).

    Anybody facing the same?

×
×
  • Create New...