Jump to content

gebeer

Members
  • Posts

    1,393
  • Joined

  • Last visited

  • Days Won

    39

Posts posted by gebeer

  1. There is quite a lot of WP bashing going on here in the forums. I can totally understand the reasons for that and agree with most of what is being said.

    What I don't understand is why people feel the need to go into this over and over again. No offense intended here.

    I think that in the long run people who responsibly build and maintain websites will eventually move away from WP to other platforms like PW.

    I introduced PW to an agency that I'm freelancing for and since then they started to do most of their projects with PW.

    Seeing the fast growing PW community also indicates that people are able to make choices based on their experience with other platforms and what they see can be achieved with PW.

    From an energetic point of view it is preferable not to put your energy into something that you don't want or like. Any energy that we put into those things will most likely help to support them even if we don't intend to do so.

    So I just leave WP be what it is and concentrate on all the wonderful things that I can do with PW :)

    • Like 8
  2. ProcessWire API has methods for session handling: $session

    To set your custom session variable you can use $session->set($name, $value) or $session->$name = $value and later retrieve it with $session->get($name) or $session->$name

    So in your case it would be

    if($config->ajax) {
        $session->test = "test";
    }
    

    Here test will only be set if you make an ajax call to the page. From your question it is not clear whether you made that ajax call before trying to get the test value on a normal page load.

    To retrieve the value you can use

    $test = $session->test;
    
    • Like 3
  3. <div class="thumbnail">
    <a href="...">  (Link to my gallery)
         <div class="flex-item6" style="background-image:
         (<?php echo $image=$page->images->get ("chrysanthemum_thumbnail.png")->url; ?>)">
    <span class="overlay">stuff</span>
    </a>
    </div>
    
    

    In your inline style you are missing the url() part. And the api call to the image is also not correct. Is the image field storing only 1 ore multiple images?

    If it is multiple, you need to do something like

    <div class="thumbnail">
    <a href="...">  (Link to my gallery)
         <div class="flex-item6" style="background-image:
         url(<?php echo $page->images->first()->url; ?>)">
    <span class="overlay">stuff</span>
    </a>
    </div>
    
    • Like 2
  4. Just wanted to note here that with PW 2.6.x the pwimage plugin stopped working. So I couldn't insert images in CKEditor anymore. I discovered that in the config json array with PW 2.6 a element "modals" got added (through /wire/config.php around line 848).

    You need to add this to the $jsConfig like:

    	<script>
    	<?php
    	$config = $this->wire('config');
    	$jsConfig = $config->js();
    	$jsConfig['modals'] = array(
    		'large' => "15,15,30,30,draggable=false,resizable=true,hide=250,show=100", 
    		'medium' => "50,49,100,100", 
    		'small' => "100,100,200,200",
    		'full' => "0,0,0,0",
    	);
    	$jsConfig['urls'] = array(
    	    'root' => $config->urls->root,
    	    'admin' => $config->urls->admin,
    	    'modules' => $config->urls->modules,
    	    'core' => $config->urls->core,
    	    'files' => $config->urls->files,
    	    'templates' => $config->urls->templates,
    	    'adminTemplates' => $config->urls->adminTemplates
    	);
    	?>
    	var config = <?php echo json_encode($jsConfig); ?>;
    	</script>
    
    

    Then the modal popups for inserting images will work again. See also my thread about pwimage plugin in frontend forms.

    • Like 1
  5. After an upgrade from 2.5.2 to 2.6.3 my setup stopped working  :(

    I cannot choose and insert images anymore in my frontend form CKEditor field with the pwimage plugin. If I click on the insert image button in the editor toolbar, nothing happens and it throws a js error:

    TypeError: config.modals is undefined modal.js (line 66, col 5)

     

    It seems the way the pwimage plugin works changed significantly.

    I guess I need to load some additional scripts in the frontend to make this work again but I can't seem to find what is missing.

    Any help would be much appreciated. 

    EDIT

    To make frontend forms work, I added this to the head:

    	<?php if ($user->isLoggedin()) { ?>
    	<script>
    	<?php
    	$jsConfig = $config->js();
    	$jsConfig['urls'] = array(
    	    'root' => $config->urls->root,
    	    'admin' => $config->urls->admin,
    	    'modules' => $config->urls->modules,
    	    'core' => $config->urls->core,
    	    'files' => $config->urls->files,
    	    'templates' => $config->urls->templates,
    	    'adminTemplates' => $config->urls->adminTemplates
    	);
    	?>
    	var config = <?php echo json_encode($jsConfig); ?>;
    	</script>
    	<?php } ?>
    
    

    This outputs a JS config variable in json format. When I compare the output of config from the admin page edit source to my frontend page edit source, I find that following part is missing in the config json on the frontend:

        "modals": {
            "large": "15,15,30,30,draggable=false,resizable=true,hide=250,show=100",
            "medium": "50,49,100,100",
            "small": "100,100,200,200",
            "full": "0,0,0,0"
        },
        "JqueryWireTabs": {
            "rememberTabs": 0
        },
    
    

    Now what do I need to add when building the json via PHP so that this gets included also on the frontend?

    EDIT2:

    I think I found it. In wire/config.php around line 848 there is

    $config->modals = array(
    	'large' => "15,15,30,30,draggable=false,resizable=true,hide=250,show=100", 
    	'medium' => "50,49,100,100", 
    	'small' => "100,100,200,200",
    	'full' => "0,0,0,0",
    );
    
    

    I added this to my code so it now reads:

    	<?php if ($user->isLoggedin()) { ?>
    	<script>
    	<?php
    	$config = $this->wire('config');
    	$jsConfig = $config->js();
    	$jsConfig['modals'] = $config->modals;
    	$jsConfig['urls'] = array(
    	    'root' => $config->urls->root,
    	    'admin' => $config->urls->admin,
    	    'modules' => $config->urls->modules,
    	    'core' => $config->urls->core,
    	    'files' => $config->urls->files,
    	    'templates' => $config->urls->templates,
    	    'adminTemplates' => $config->urls->adminTemplates
    	);
    	?>
    	var config = <?php echo json_encode($jsConfig); ?>;
    	</script>
    	<?php } ?>
    
    

    And, voila, the modal for selecting images is now working again on my frontend form  O0

    • Like 2
  6. I updated my site from 2.5.2 to 2.6.3 with the ProcessUpgrade Module.

    When updating InputfieldTime (also through ProcessUpgrade Module) I got a worning that it is not compatible with 2.6. I went ahead anyways to see what will happen.

    After upgrade I got 2 Warnings:

    ModulesDuplicates: There appear to be multiple copies of module "FieldtypeTime" on the file system. Please edit the module settings to tell ProcessWire which one to use:FieldtypeTime
    ModulesDuplicates: There appear to be multiple copies of module "InputfieldTime" on the file system. Please edit the module settings to tell ProcessWire which one to use:InputfieldTime

    and a message:

    InputfieldTime was updated successfully.

    Button: Continue to module settings

    In the module settings I got:

    There are multiple copies of this module. Select the module file you want to use.
     
    /site/modules/InputfieldTime/InputfieldTime.module (the new one after update)
    /site/modules/PW-FieldtypeTime/InputfieldTime.module (the old one)
     
    I chose the new one.
     
    Then I did the same for Fieldtype Time module.
     
    Everything seems to be working fine with 2.6.3
     
    Just wanted to let you know.
     
  7. Yeah, stupid me :-[

    Forgot that $images will be altered after removing.

    When I do

                    $images = $page->images;
                    echo count($images) . " images<br>";
                    foreach ($images as $img) {
                        echo $img->basename . "<br>";
                    }
                    $firstimage = $images->eq(0);
                    echo "firstimage<br>";
                    echo $firstimage->basename . "<br>";
                    
                    $restimages = $images->remove($firstimage);
                    echo "restimages<br>";
                    foreach ($restimages as $img) {
                        echo $img->basename . "<br>";
                    }
    
    

    everything works as expected

  8. Hi All,

    I have an images field for multiple images set to always return an array.

    My images field holds 5 images.

    I'm trying to get the first image of the array and then remove that to get an array that holds images 2-5.

    Here's my testing code so far

                    $images = $page->images;
                    $firstimage = $images->eq(0); //also tried $images->first() with same result
                    $restimages = $images->remove($firstimage);
                    echo count($images) . " images<br>";
                    foreach ($images as $img) {
                        echo $img->basename . "<br>";
                    }
                    echo "firstimage<br>";
                    echo $firstimage->basename . "<br>";
                    
                    echo "restimages<br>";
                    foreach ($restimages as $img) {
                        echo $img->basename . "<br>";
                    }
    
    

    And here's the output:

    4 images
    mario_florenz_1.jpg
    mario_florenz_3.jpg
    mario_florenz_2.jpg
    mario_florenz_5-1.jpg
    firstimage
    mario_florenz_4.jpg
    restimages
    mario_florenz_1.jpg
    mario_florenz_3.jpg
    mario_florenz_2.jpg
    mario_florenz_5-1.jpg 

    A few things that buffle me:

    -count($images) returns 4 where it should be 5

    -foreach through $images returns only 4 images where it should be 5

    -$images->eq(0) returns the first image but this one is not returned when I loop through all images

    -$images and $images->remove($firstimage) return the same

    I really don't understand what is happening here. Reading through the API docs on images and WireArray manipulation it seems my code should work.

    Any help would be much appreciated.

  9. I was not sure from your first post whether you just wanted to collapse the field when empty. That is why I included those instructions.

    Further down in my first post I describe that I have the same behaviour here on a 2.5.29 dev site with multi language setup.

    This is to confirm your problem.

    Looks like a bug to me. Maybe you want to file an issue at github.

  10. You don't need dependencies for this to work if you want to show the image_field itself only when there are images.

    In the field settings for your image_field go to input tab -> visibility and choose "Collapsed only when blank". This should do what you want.

    EDIT:

    I just tried this on a 2.5.29 dev install and I can confirm that it is not working as expected.

    I have a field images and a field bodycopy.

    For bodycopy I choose "Show this field only if..." images.count>0

    The bodycopy doesn't show at all, no matter if there is an image in the images field or not.

    The field is there in the HTML with an attribute data-show-if='images.count>0' in the field wrapper.

    Maybe the JS cannot compute the >0 part. But this is just a guess and needs further investigation.

    Should we file this as bug?

    EDIT2:

    I tested this in a multi language setup. In the dependencies documentation section limitations it says

    Field dependency selectors may not yet query the value of a multi-language field. However, they can show/hide multi-language fields according to the value of other fields.

    Do you also have a multi language setup?

  11. Thanks for your reply.

    $warning will not be available inside the each() callback function because of variable scope.

    Also the callback function needs to either echo or return something.

    So I'm afraid your code won't output anything and give a PHP notice like "variable $warning not defined" because you define $warning outside the callback function. This is mentioned in the link that I posted in #1

    EDIT

    Sorry, I overlooked the "use (&$warning)" part. So forget about what I just said

    I implemented your proposed solution. But still the return value gives me the page ids of pages within the $divesites page array where I would expect it to be empty.

    EDIT again

    Got it. I still had $warning = $divesites->each(function...

    After removing the $warning = part, it works.

    Only I had to replace {title} with {$item->title}

    Thanks again.

    But with my limited PHP knowledge I still don't understand why that is so.

    • Like 1
  12. Hello,

    I'm playing with the new each() API method.

    	$warning = $divesites->each(function($item) {
    	  $warning = "";
    	  if (!$item->marker->address) {
    	  	$warning .= "<div class='alert alert-warning'>coordinates for {title} not set</div>";
    	  } else {
    	  	$warning .= "";
    	  }
    	  return $warning;
    	});
    
    

    $warning should return an empty string, when all dive site adresses are set. But instead it returns the page id of the last dive site in the loop.

    When I do it the foreach way

            $warning = "";
    	foreach ($divesites as $site) {
    		if (!$site->marker->address) {
    		  	$warning .= "<div class='alert alert-warning'>coordinates for {$site->title} not set</div>";
    		  } else {
    		  	$warning .= "";
    		  }
    	}
    
    

    the $warning is an empty string as expected.

    Why is that? Any pointers would be much appreciated.

  13. I installed an additional language on 2.5.27 dev and everything went fine.

    Now I added a 3rd language and get several errors:

    Session: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_title.data1372' in 'field list'

    Session: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'data1372'

    Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data_exact1372'

    Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data1372'

    and warnings

    Session: language is missing column field_title.data1372

    Session: language nl is missing column field_title.data1372

    Prior to installing the 3rd language I created an options field. Upon entering the transaltion for the field options I got errors but I didn't note them down. But I cannot save translations for the options. Field for entering translations remains blank after save.

    Maybe add language error is related to the problems with that options field?

    I removed the 3rd language and upgraded to 2.5.29 dev. But same errors when adding the 3rd language again.

  14. You might want to show them the Canton speakers site done with PW that was introduced lately and also announced in PW weekly newsletter. This is a worldwide brand. If they trust in PW, why shouldn't your potential customer.

    EDIT

    And cmscritic.com might serve as an example. Their article ProcessWire vs WordPress has some good arguments for PW and against WP.

    Then there is this article about PW in the german IT magazine c't: "German computer magazine c't has just published an article about ProcessWire, and Tuts+ has announced they are going to commission tutorials on ProcessWire" (taken from PW weekly #43).

    Some ideas for your points 2 and 3:

    - you could offer free updates for a period of time since it is so easy to do

    - if you have the capabilities, you could offer a free port of the system to WP or Drupal in case PW development will stop in the future. This will underline your total confidence in PW

    And, if you have the opportunity, you could show them the PW backend and how easy it is for editors to work with.

    • Like 6
×
×
  • Create New...