Jump to content

JoshoB

Members
  • Posts

    115
  • Joined

  • Last visited

Posts posted by JoshoB

  1. So I have another problem.

    On one of our websites, we sell educational books. Each book is assigned to one or more categories. Yesterday, I added subcategories and assigned books to them. The structure for the categories are as follows:

    • Home
      • Categories (template: categories.php)
        • Category (template: category.php)
          • Subcategory (template: category.php)

    Books are assigned categories via a PageArray field (with asmSelect) also called "categories". Books themselves have a template "product.php" and are grouped under "Products" (with template "product.php").

    To make sure books are listed in the proper category on the website, I used this selector:

    $selector = "template=product, limit=10, categories.parent=$page, sort=$sort_results";

    $sort_results is a simple variable to switch between alphabetical sort, sort by release date, etc. 

    The issue is the categories.parent=$page element. To my mind, this should list products that have a category that is either the requested page (people are browsing the "Latin" category), as well as all subcategories.

    The problem is that products in subcategories are ignored by ProcessWire. So if a book is listed in "Latin" and another has a category that's a child of "Latin", the first book is shown when I'm browsing the "Latin" category, but not the second one. The second one is shown ony if I go to the subcategory page.

    Does someone have a solution for this issue? I just want the category page to list all products in that category including subcategories.

    Thank you!

     

     

  2. 9 minutes ago, kongondo said:

    A couple more things:

    1. Does asm work on other page fields?
    2. Does asm work on other templates? 
    3. Does switching to another inputfield (e.g. autocomplete) work? What about switching back to asm?
    4. Clearing cache? 

    I'm out of ideas save for having a quick look at it if that's possible. 

    1. No, asm is broken on every field that uses it.
    2. No, templates don't seem to matter: it's the asmSelect field that's broken somehow.
    3. AutoComplete works as expected. Switching back to asmSelect has no effect.
    4. Which cache? Cache module is not activated.
    5 minutes ago, Peter Knight said:

    I'd say it's a PHP version issue. 

    How so?

    Other websites on the same server don't have the issue with asmSelect that this website for some reason has.

  3. 2 minutes ago, Autofahrn said:

    Blind shot: Could the PHP version had been changed on that site (hard to believe this could cause such an issue, though)? 

    No, not to my knowledge. I would have received a notification.

    I upgraded ProcessWire to the latest version, as I said before, and there were no errors. All other JavaScript in the backend seems to work fine, except for the asmSelect. It's utterly baffling!

  4. Just now, kongondo said:

    Hmm, that's strange. Does JavaScript work OK in other pages? E.g. CKEditor working fine? 

    Yep, works exactly as it should.

    TracyDebugger is shown in source, but not rendered in the browser at all.

    <script src="/admin/page/?_tracy_bar=js&amp;v=2.5.6&amp;XDEBUG_SESSION_STOP=1" data-id="289de0c670">

    Weird.

    And now I get "Unknown error" when loading the PageTree, so I'm uninstalling Tracy.

  5. 14 minutes ago, kongondo said:

    I would have placed my bet on JavaScript as well. A couple of things to consider:

    1. Check for JavaScript errors and missing JavaScript files 
    2. Did the page reference field settings change? (just fishing with this one :-)) 
    3. TracyDebugger: install and debug with this great tool 
    4. Any errors if config->debug is true?
    1. It must be a JavaScript issue (I expect), but no errors show up.
    2. Nope, not as far as I know. Haven't done anything with the website recently. Just today I noticed the asmSelect doesn't work anymore.
    3. I installed TracyDebugger, set it to development mode, but I don't see the bar anyway. Could it be related to the asmSelect issue?
    4. It is now, but again no messages regarding errors.

     

     

  6. This is, I expect, going to be nearly impossible to track down, but on one of my websites, the asmSelect has suddenly stopped functioning. It should use jQuery (IIRC) to allow a user to add, delete and reorder pages from a list. But for some reason, on this website (and this one only), the asmSelect doesn't "activate", and it's shown in the backend as a regular multiple select box instead. Another website (a near duplicate of this on as far as structure is concerned) works as usual.

    I've upgraded ProcessWire to the latest version, thinking that this would perhaps solve it, but no dice. I haven't changed anything on the website for a while. So this is an utter mystery to me.  Does anyone here have an idea of where to look to figure out what went wrong? Thank you in advance.

    Edit: attached images of what it should look like (with green elements) and what it now looks like.

    asm_good.png

    asm_bad.png

  7. 6 minutes ago, Robin S said:

    Don't do this part...

    Yeah, I know. Like I said, I rewrote this countless times and in the end I thought "Maybe it helps if I store the $word as a separate variable?"

    Anyway, I made some changes. The modified part now looks like this:

    // Should this page be moved?
    if($word->parent->template != "exercise") {
    
    	// Disable output formatting
    	$word->of(false);
    	$parent = wire('pages')->get("parent=$page, template=exercise, name=exercise-$number"); 
    	if($parent->id) {
    		$word->parent = $parent; 
    	} 
    	else {
    		die("Error: parent doesn't exist?"); 
    	}
    		
    	// Save
    	$word->save;
    
    	// Re-enable output formatting
    	$word->of(true); 
    }

    And it does nothing: it just runs the script and doesn't give an error, doesn't move the pages, etc.

  8. So I've been trying to do something seemingly simple. I performed a search here and I keep getting similar results, so I'm sort of lost as to what I'm doing wrong.

    The issue is as follows: I'm building a website where people can train their vocabulary for different languages. It's based on books we've published. At first, I imported all the data as just one big pile of words, with the exercises and sentence numbers added to the file. But now, it's more useful to organize the pages differently, with separate words having a new template as their parent based on the exercise.

    Let me illustrate for a moment.

    The present situation looks like this:

    Home (home)
    |-Language
    |  |-English (words)
    |     |-Word #1 (word)
    |     |-Word #2 (word)

    What I'm trying to do is create the following:

    Home (home)
    |-Language
    |  |-English (words)
    |     |-Exercise #1 (exercise)
    |     |  |-Word #1 (word)
    |     |  |-Word #2 (word)
    |     |-Exercise #2 (exercise)
    |     |  |-Word #3 (word)
    |     |  |-Word #4 (word)

    Fortunately, every word has a field "exercise" that lists the number of the exercise in question. So it shouldn't be too hard to insert the proper parent page here. Or so I thought, at least.

    Since this is a one-time operation, I wrote some quick-and-dirty code in the "words" template. It looks like this:

    // Collect the words
    $words = $page->children->find("template=word,exercise>0,exercise<=1"); 
    
    // Cycle through words
    foreach($words as $word) {
    
    	// Does an exercise exist with this number?
    	$number = trim($word->exercise);
    	if($number < 10) $number = "00$number";
    	elseif($number < 100) $number = "0$number"; 
    
    	// If the page doesn't exist, create it
    	$exercise = $page->children->get("template=exercise, name=exercise-$number");
    	if(!$exercise->id) {
    		$p = new Page(); 
    		$p->template = 'exercise'; 
    		$p->parent = $page; 
    		$p->name = "exercise-" . $number; 
    		$p->title = "Oefening " . trim($word->exercise); 
    		$p->save();
    	}
    
    	// Should this page be moved?
    	if($word->parent->template != "exercise") {
    
    		// Disable output formatting
    		$p = $word; 
    		$p->of(false);
    		$parent = wire('pages')->get("parent=$page, template=exercise, name=exercise-$number"); 
    		$p->parent = $parent; 
    
    		// Save
    		$p->save;
    
    		// Re-enable output formatting
    		$p->of(true); 		
    	}
    }

    Now, I've rewritten this countless times. The script does create the new pages with the "exercise" template, right where they should be, but it doesn't change the parent of the pages with template "word" to these new pages. I honestly don't see what I'm doing wrong, but undoubtedly someone here will glance at it and go, "Hey, you oughta do this!" and I'll slap my forehead and wonder why I didn't think of it.

    Anyway, thanks in advance!

     

     

     

  9. So I've been working on a website where large files don't get uploaded via the Ajax drag-and-drop thing. These are files in excess of 100 MB. I've tried uploading a file of 160 MB and one of 250 MB and neither of them work. The progress bar gets to 100% and then nothing happens. I let it stay there for a few minutes, but it never gets resolved. Large files just don't get uploaded to the server for some reason.

    I've also tried the trick where initHTML5 is replaced by InitOldSchool in the javascript file for the uploader (i.e. InputfieldFile.js in wire/modules), but still no dice.

    These are the settings on the server/PHP.ini:

    extension=apc.so
    session.save_path = "/tmp"
    
    upload_max_filesize = 1024M
    post_max_size = 1024M
    max_execution_time = 36000
    max_input_time = 36000
    memory_limit = 2048M
    always_populate_raw_post_data = -1
    date.timezone = "Europe/Amsterdam"
    mail.add_x_header = On
    enable_dl = Off
    disable_functions = show_source, system, shell_exec, passthru, exec, phpinfo, popen, proc_open

    And .htaccess:

    php_value upload_max_filesize 1024M
    php_value post_max_size 1024M
    php_value memory_limit 1024M
    php_value max_execution_time 36000
    php_value max_input_time 36000

    And also this in .htaccess:

    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>

    I don't see what the problem could be. But perhaps I've been looking at this for so long I just don't see the answer.

    If anyone around here can help, that would be grand! Thanks.

  10. Hello again!

    Sorry for the delay. I finally got around to trying this:

    authors.authors_name.title%=$q_word

    But get an error: Error: Exception: Multi-dot 'a.b.c' type selectors may not be used with OR '|' fields

    Guess it's a bit too complex the way that it is now, with pipes (OR) between the different fields. The way it is now (see above) works, even though I have PHP skip numbers that the user may have entered (since I don't think that will be too much of a problem).

    I should probably buy the ProFields module at some point: the Table Fieldtype looks extremely useful.

  11. On 07/12/2017 at 8:46 PM, cstevensjr said:

    Very good article.  I also like how they don't hide information regarding developing this website,  to include both a Changelog and Roadmap section under their "Dev Index"

    https://www.ancientworldmagazine.com/dev/

    Cheers! Yeah, I guess I should have posted the link here, too.

    I've been developing with ProcessWire for a few years now (and bugging the community here with whatever issues I ran into -- which so far have always been my own fault!). I just wanted a place where I could explain how and why I picked ProcessWire as my CMF of choice, and to sort of explain a bit how this particular website gets made. I plan to add more to the blog about how some of the stuff works, what my rationale is behind some things, etc. Might not always deal exclusively with ProcessWire, but some upcoming topics will deal with how I handled the watermark branding on social media images (with the great PageImageManipulator module and some creative switcheroo in the PHP code of templates) and how I went about to create the structure and code for a timeline (which isn't online yet due solely to the fact that it has too little content yet).

    I always like reading patch notes, so I figured I'd add a changelog to the website to keep those who are interested in these kinds of things to keep track of changes that I implement. The roadmap is there to sort of explain where we're going with the website, even if one or two things that are a bit more experimental are kept under wraps (since they may never lead to anything); it also helps remind me what I'm supposed to be working on.

    • Like 11
  12. On 03/11/2017 at 9:03 PM, Robin S said:

    I'm curious about the setup of the authors field. The authors field is a Repeater, and then inside that Repeater is a Page Reference field, and the selectable pages of that field contain name fields for the author? Why so complex? Wouldn't it be possible to remove one of these levels and use either a Repeater or a Page Reference field for author?

    Hi Robin. It's complex because there's no other way to do this, I think. Here's an overview of the structure:

    • The page in question is a book (template=product) with a repeater field called "authors".
    • Each element of the repeater field is a block: a PageArray that lists all authors (with template=author) under /authors, plus three checkboxes (to indicate that the author is actually an editor and/or a translator and/or writer of the book's introduction).
    • Since a book often has more than one writer (and/or editor, translator, etc.) I need the ability to add multiple instances of this block, hence the repeater field.

    In addition, because the author is a page, I can load that author's page and then list all books associated with that author on his/her page (using $pages->find). I find that advantageous. I also dislike having to re-enter data twice, so by using a PageArray I can (a) see if the author is already in the database and (b) if so, add him/her to the field or (c) otherwise create a page for that author. This has the added benefit of making sure that author names are consistent across the site (e.g. no "J. Smith", "John Smith", "John J. Smith", etc. that are actually all the same writer).

×
×
  • Create New...