Jump to content

Dean

Members
  • Posts

    60
  • Joined

  • Last visited

Posts posted by Dean

  1. I'd be grateful if people could offer some advice on the best set up to allow users to vote for their favourite page. Registered users will be able to choose a 1st, 2nd, 3rd and 4th place page. Once voting is closed, the page with the most 1st place votes will be the winner, followed by the most 2nd place votes and so on.

    I did think of adding some fields to the user template, e.g. 1st_place_page, 2nd_place_page, 3rd_place_page, 4th_place_page. These would hold the ID of the page that they voted for. Then I could loop through all the users and calculate the totals. The issue is that there are lots of different categories to vote on, so that would mean adding 1st, 2nd, 3rd, 4th place fields for each category to the user template. Is there a better way of doing this that anyone can suggest? Thanks!

  2. Sorry @BillH, I had to work on something else for a few days. So, back to this. If I change

    $traders = pages($selector);

    to

    $traders = $pages->find($selector);

    I get

    Notice: Undefined variable: pages
    Fatal Error: Uncaught Error: Call to a member function find() on null

    Regarding sorting, I'm sorting by title if I haven't specified a search string

    if(strpos($selector, "~=") === false) $selector .= "sort=title, ";

    If there is a search string, are the results not sorted by ProcessWire according to relevance?

  3. Thanks @BillH, I'm using the code from the Skyscraper demo:

    // check if there are any keyword searches in the selector by looking for the presence of 
    // ~= operator. if present, then omit the 'sort' param, since ProcessWire sorts by 
    // relevance when no sort specified.
    if(strpos($selector, "~=") === false) $selector .= "sort=name, ";

    I'm using renderPager():

    $traders = findTraders($selector, 5);
    $pager = $traders->renderPager();
    ...
    echo $pager;

    findTraders() is a slightly modified version of findSkyscrapers()

    function findTraders($selector, $limit=10) {
    	// check if there are any keyword searches in the selector by looking for the presence of 
    	// ~= operator. if present, then omit the 'sort' param, since ProcessWire sorts by 
    	// relevance when no sort specified.
    	if(strpos($selector, "~=") === false) $selector .= "sort=title, ";
    	
    	$selector .= "limit=$limit";
    
    	echo '<small>'.$selector.'</small><br />';
    	
    	// now call upon ProcessWire to find the skyscrapers for us
    	$traders = pages($selector);
    
    	return $traders;
    }

     

    • Like 1
  4. I have an issue with ordering and repeated results when limiting search results and splitting into pages. Selector is shown just above letters.

    This is what I get when all results fit on one page:

    Untitled-3.jpg.57f434c1e139c0733b78eac53df5b7d7.jpg

    If I limit to 5 per page, I get a different order, missing results, and a repeated result on page 2:

    Untitled-2.jpg.fc02b92b082b3b3ea9c1de13869a9eee.jpg

    Untitled-1.jpg.70713d653c04d9a2f63f3cd812154f0b.jpg

    Can anyone shed any light please?

  5. Dear community

    I have put a site live by FTPing files, copying database, updating config, emptying cache DB table. But I now have this:

    Fatal Error: Uncaught Error: Call to a member function execute() on null in /var/www/vhosts/mydomain.com/httpdocs/index.php:55

    Can anyone help please?

  6. Actually, it was my fault. I hadn't matched the title to the relevant form field in My Form > Actions > Save to ProcessWire Pages > Page Fields to Form Fields.

    While we're discussing this, is there a way to trigger an email when sending the form entry to a page. I'd like to be able to tell the user their log in name and password and tell them they can log in now.

  7. The reason I was creating another user template was because I think there is no name field on the user-hunt template which I think is what was causing the issue with the weird name that was being added when a new user registered. Can you add the name field for me?

  8. Hi @teppo,

    • Every single page is triggering the error, so I can't even get into PW admin
    • I've not changed/updated any modules. The only one I had installed was form builder with stripe
    • I've not update ProcessWire

    It was all working fine yesterday. Then I came to look at it this morning and I'm getting this. And I was already on I tight schedule to get it done. ?

  9. Hi @psy, all I have in the log is

    2020-06-01 10:28:59	?	http://[url].com/register/	Recoverable Fatal Error: 	Argument 1 passed to ProcessWire\Users::setCurrentUser() must be an instance of ProcessWire\User, instance of ProcessWire\Page given, called in /var/www/web/wire/core/Session.php on line 188 and defined (line 68 of /var/www/web/wire/core/Users.php)

    I thought that I was maybe overwriting $user somewhere, but I've searched for $user and there are none.

  10. I'm not sure what I've done, but I'm getting a fatal error on every page now. I've tried reverting back to an older copy of the site but there's no change. Can anybody help please?

    Catchable fatal error: Argument 1 passed to ProcessWire\Users::setCurrentUser() must be an instance of ProcessWire\User, instance of ProcessWire\Page given, called in /var/www/web/wire/core/Session.php on line 188 and defined in /var/www/web/wire/core/Users.php on line 68

     

  11. 44 minutes ago, Jan Romero said:

    it’s unclear where the variables after the call to createUser() come from

    Sorry, I just left that part of the code out. They are being grabbed from the form and run through the sanitizer.

    I'm using only the form builder module (with stripe payment).

    All the data for the user is populated correctly. The page title is set correctly as the name that is entered on the form.

    The URL and the settings > name are the only things that are wrong. See these images:

     

    Untitled-1.jpg

    Untitled-2.jpg

×
×
  • Create New...