Jump to content

charger

Members
  • Posts

    111
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by charger

  1. I'm slowly getting into module development. My aim is to - in a first step - convert Ryans TextformatterVideoEmbed module to the new module structure he proposes in the Helloworld module. In a second step, I'd like to add some more options to the module. My fork can be found here.

    However, I'm having a problem with the getModuleInfo function. As soon as I replace it with a TextformatterVideoEmbed.info.php file, I start getting the following error when I edit a field like title (text) or body (textarea):

    Method TextformatterVideoEmbed::getModuleInfo does not exist or is not callable in this context

    Additionally, the Details tab of that field is not shown at all.

    Am I missing something? Do textformatters have special requirements in this term?

  2. I also use somas script and actually tried to enhance it a little. However I'm stuck with line 23:

    if($inputfield->name != 'images') return; // we assume images field
    

    What if I have multiple file upload fields for images that should all use this script? Is there no way to do something like...

    if(!($inputfield->type instanceof FieldtypeImage)) return; // not working!
    

    ...instead to not have to assume a certain field name?

  3. I've attached the screenshot of my settings.

    The PDF allows max one file and does overwrite existing files.

    There's also just this file field on the page.

    I created multiple new pages to make sure there are no leftover duplicates in the assets/files folder.

    The website is not hosted on a Windows server.

    Hmm.. I don't have any clue what else could cause it.

    post-2284-0-23987200-1432129258_thumb.pn

  4. Thanks for the quick update, it again works as expected!

    The -1 suffix still happens though with the "Rename on Save" option enabled. So whenever I hit Save, the filename alternates between having the suffix and not.

    Let me know if you need other specific info.

  5. Hi Adrian,

    I've got a problem when using fields in the filename format that are populated at the same time as the upload field (PDF in my case). The format looks like this:

    customer-{$page->customer_id}

    When a new page is created, the user fills in a value into the customer_id field and then uploads a PDF, which should get renamed. However, the value inside customer_id is not respected, as the PDF gets renamed right after upload and before hitting Save. A click on Save also doesn't rename it again.

    I remember this worked a couple of versions ago, but not anymore. Did you change something in that area?

    Using "Rename on Save" isn't an option as I need the filename to stay the same and not add a -1 suffix every second save.

  6. Thanks for your answers, I've used the following (slightly modified code) in my template to get it work:

    if(!$input->urlSegment1) throw new WireException(); // check for url segment
    $filename = $sanitizer->pageName($input->urlSegment1); // sanitize url segment (filename)
    $p = $pages->get("files=$filename"); // search all pages for $filename in field files
    if(!$p->id) throw new Wire404Exception(); // check if page exists
    $session->redirect($pages->get($p->id)->job_pdf->url); // redirect to file
    

    For some reason, the additional viewable() check for $p always resulted in a 404 error. So I removed it.

  7. I need assets (PDF files) from multiple pages to be accessible from a single URL. That means, instead of

    http://www.domain.com/assets/files/1011/example1.pdf
    http://www.domain.com/assets/files/1012/example2.pdf
    ...
    
    it should be e.g.

    so without the page ID in the URL.

    The reason I need it this way, is because:

    1. I can't use a single page to save all files (PDFs) in it, as there are additional fields to every PDF. That means I need PageTable or Repeater, and both create new pages for every PDF
    2. There's a 3rd party service that links from external pages to the PDFs. That service however doesn't know about the page ID in the URLs, it only knows the filename of the PDFs.

    I've found the following topics in the forum that somewhat touch my subject, but I couldn't make them work for me:

    https://processwire.com/talk/topic/8312-creating-my-own-folders-for-image-assets/

    https://processwire.com/talk/topic/4127-can-assets-folder-be-moved-to-another-domainsubdomain/

    Any idea on how I could solve this?

  8. Hmm, or maybe I should include this in the present module but with a max 3-way relationship? Otherwise it get messy if more. The 3rd relationship (materials in your case) would only kick in if user configures it in the Fieldtype settings as you suggested. What do you guys think?

    I obviously would love to see this being added :) But it might be error prone on the input side of things. You'd have to tell the user exactly what's allowed and how to enter it. I think this needs a bit more thinking on how it can be best integrated.

    • Like 1
  9. Great stuff!! Thanks a lot! I did some testing, and everything seems to work.

    I have one feature that I'm missing. I'm aware this is not the core idea of this module, but I wanted to mention it anyway. Ok, so here it is:

    If I have a selector for columns/rows that goes like parent=1283|1284, it works as expected by listing the children of both parents. The output could be like this:

    S
    M
    L
    Cotton
    Nylon

    However, it would be cool to have an option (checkbox) that creates all possible combinations of the selected children, like this:

    S Cotton
    M Cotton
    L Cotton
    S Nylon
    M Nylon
    L Nylon

    In my case, I need this because I have multiple currencies for the rows.

    As mentioned, I don't know if this too much out of scope and maybe needs an additional module.

    • Like 1
  10. The problem is that if I upload 10 files at a time and they all get renamed to tmp-filename.pdf before saving, then I have no chance to see the original filename and thus write the according description to it.

    An example: I upload a file that is originally named 30_10_2014_EventHappyMonday.pdf. In order to know what to fill in in the description field (in this case it would be "Event Happy Monday"), it helps a lot if I still see the original filename and not tmp-filename.pdf.

    Enjoy your holidays!

  11. Supposed I upload multiple files at a time and want them to be rename to the following format format:

    mysite-[Y-m-d]-{$file->description}

    The problem is that all the files get renamed immediately (before hitting the save button) like this:

    tmp-filename.pdf
    tmp-filename-1.pdf
    tmp-filename-2.pdf
    ...

    Now, how can I tell which tmp-filename belongs to which original file? Sure, I could still open the files by clicking on their filename. But what if the new file format would only be applied after hitting the save button?

  12. I think we got tangled up in my use case. Maybe I have to go back to the beginning, because what I'm looking for has different use cases in my opinion.

    What I'm looking for is to have some kind of matrix fieldtype where I can define the row and column headers. Now, these headers should automatically be built by the page title of definable pages (actually their respective child pages).

    Say I have two pages (Size and Color) with the following child pages:

    Size

       – S

       – M

       – L

     

    Color

       – Red

       – Blue

       – Green

    Now in this matrix fieldtype, I could apply Size to be the row header and Color the column header. This would result in a matrix like this:

       | Red | Blue | Green |

    –––––--------------------

    S  |     |      |       |

    –––––--------------------

    M  |     |      |       |

    –––––--------------------

    L  |     |      |       |

    –––––--------------------

     
    Now, if I add another child to the page Color (e.g. Black), the matrix would be automatically extended: 

       | Red | Blue | Green | Black |

    –––––----------------------------

    S  |     |      |       |       |

    –––––----------------------------

    M  |     |      |       |       |

    –––––----------------------------

    L  |     |      |       |       |

    –––––----------------------------

    Is there already a fieldtype like that?

  13. I'm not sure if I can follow your example. Let me add another screenshot to clarify my setup. I have a product page (T-Shirt) that is displayed on the frontend. Then, there's the Tools page (only for backend), where I define a products attributes and categories.

    Now, within the page T-Shirts (which represents a product category) I want to be able to have the table I mentioned above where I can set the prices for each product variant of the attributes size and color – pretty much as in my other screenshot above.

    The product page T-Shirt then actually just has a drop-down to select a product category (in this case T-Shirts).

    post-2284-0-83345600-1412457938_thumb.pn

  14. It really sounds like you want ProFields, the table plugin is extremely flexible. Are you wanting to make changes to all of you separate pages via one template, or are you still wanting to edit all of the pages directly?

    As I mentioned at the beginning, I already tried to use the ProFields Table, Multiplier and Page Table. The screenshot in my post above is actually from the ProFields Table fieldtype.

    It should be one template in the end that I can use on different pages (-> product categories).

  15. It might help if I add a screenshot of what it looks like if it's manually built with the fieldtype table. The downside is that I have to create all possible variations by hand, and that if I add a new currency or a new product option, it's not populated automatically to this table.

    One solution (at least for the product options size and color) to this would be if the fieldtype table would allow columns to be of the type page and then output them as radios/checkboxes.

    It would be even cooler of course if the variants (all possible combinations of the product options size and color) would also be built automatically ;)

    post-2284-0-06979500-1412440640_thumb.pn

  16. Not sure what you want to archive with that but I think there is a better way to solve that. So could you add some more details?

    I want to be able to set the price of a product (e.g. a T-Shirt) by its category (well, T-Shirts). Now for all products within the category T-Shirts, there are the same options (size S, M, L and color red, green, blue). So if I go to the category page of T-Shirts, I want a matrix that lists all the options of this product category and then let me set a price for each currency I'm offering the product in. I hope that's understandable :)

×
×
  • Create New...