Jump to content

Pavle

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by Pavle

  1. Dear ProcessWire buddies,

    I am on a tight schedule and I don't have a lot of time for research, so I hope any of you already had a similar case. 

    I have a form and form data will be saved as a new page.

    How would you go about implementing a nice ajax video upload (with upload progress) on frontend and then adding this video to appropriate page. Besides that, I would need a video playback in cms.

    For frontend, I guess the fastest would be to use some library -> what is ProcessWire using for it's ajax file upload? Is it reasonable to use this in frontend as well?

    I have no idea how to make a video player in cms. Probably with a custom field type, that would then render a html5 video element if video is present. Is there any documentation on creating something like that?

    I hope you will be able to help me,

    Thank you all!!

  2. Hey all,

    I have an image and text field in a repeater. When I iterate over repeater using foreach loop, image is not returned (null is returned instead), but text field is.

    • Some (I guess) useful information:
    • I am using ProcessWire 3.0.17
    • Image field supports svg format (jpg in not returned either)
    • Image filed is limited to one file and is without description
    • Image field's format is set as 'single or null', but array with field->first or field->eq(0) also doesn't work
    • Images are uploaded to server

    I used the same approach foreach($page->repeater as $item) $item->image->url a dozen time before in older versions, so I wonder if something maybe changed in v3?

    I ran out of ideas what could be wrong and what I need to change, so I hope you'll be able to help me :)

    Thanks!

    Žiga

    PS. I also noticed that I cannot add description to .svg images. Is there a special reason for this?

  3. Hey,

    It might be a bit late, but I just had the same problem after migrating site to a new server.

    The trick was to use 127.0.0.1 instead of localhost in file: site/config.php line 44: $config->dbHost = 'localhost'; 

    The solution is stated here.

    Best regards,

    Žiga

  4. I know that's it is not really relevant anymore as this topic is quite old already, but just for future reference, if somebody will stumble upon this :)

    It might be possible with css attr() function. Main support is for fetching content for :before & :after content, but there are other properties (like uri()) that are in the time of writing still experimental, but will probably get supported shortly (I hope). Read more about it here.

  5. Hey all,

    I guess I will just write here instead of starting a new topic.

    Only thing I would add to this is the ability to use any other field (rather than just the title field) as the name, or to just use the page id as the name.

    Did anybody manage to implement something like that?

    More specifically I would need title and name field to be pre-populated when creating a new page ($page->title = $page->parent->title & $page->name = "temp_".$page->title). I was planning to do it via hook in module, but I have no idea which hook would do something like that.

    Page name would than be renamed based on some field value (which I guess is simply done using "before save" hook).

    Thank you all for your help!

    EDIT:

    OK, it was actually really simple solution. I solved it by using "one-step page add" solution from above, then I used a "saveReady" hook to rename page title and page name.

    The only problem that remains now is how to check if user changed the title after. In other words: how to check if the title that is present now (before the page save) is the same as the one in the database. $page->field outputs the one from db and I don't know how to access the one from the form that was just typed in. I tried with $input, but it doesn't output anything.

    Any ideas?

    EDIT 2:

    So the answer to my last question (if somebody will need it) is:

    When attaching something to saveReady hook, one can access form values (on a new page dialog) via: $event->arguments('page')->data['field']

    For example to get to title: $event->arguments('page')->data['title']

    • Like 2
  6. Sorry, I was away yesterday :)

    @ LostKobrakai

    Of course! I completely forgot all about $template object and the whole fact that one can also manipulate templates like that :)

    @ Soma & Adriam

    Yeah, I have only one link per page, so I think that I will go with Soma's solution at the end (which is, I guess, what Adrian proposed as well :)

    If I'm lucky and there's only one link required, I solved it using a text language field, a page reference, and a url field. And handle it on template output.

    I know this post is sort of complicating about little things, but I agree with Soma...I was expecting it would be more elegant at the end (as most of other stuff in PW are).

    I am not really an expert in module building (not even an advance builder :) but I notices some other modules are doing similar stuff. For example PWlink for CKEditor has options to Link to URL, Link to Page, Link to File, Open in New window.

    The most interesting example module for "fieldtype building module" would be Repeater, without the repeating part. I checked it yesterday and it seems quite complicated, but as far as I understood the repeater field (that we include in the template) is actually a page (template) with all this other fields. I like the fact that we don't actually see those pages anywhere (like we do with the new PageTable field). I mean...i don't know I would imagine some of my clients would be a bit confused when they would see "link1", "link2" subpages (yeah, I have some interesting clients :)  

  7. Hey Adrian,

    Thanks for such a fast reply! Your solution would work perfectly if I would have only one language OR if editors would be either linking to external pages or they would remember all page-names, but I fear this approach is (in my case) prone to mistakes/errors.

    Using:

    Fieldset

    TextLanguage

    Page

    Fieldset_END

     

    ...would actually do everything that I need, it's just that every time I would want to add a link/button to a template I would need to add all this 4 fields, so I was hoping there is an easy solution for combining different fields into a new Fieldtype.

    It would be perfect if there would be something like a module for creating custom Fieldtypes, where one would just create/select needed fields (something like creating a page template, but with the ability to create fields on-the-go) and set output (html) and module would generate appropriate Fieldtype and Inputtype based on that.

    Or it would be great if there would be a Fieldtype similar to repeater, just without the ability to repeat...so in the way of selectable Fieldset (fields group)...basically if Fieldset could be added to page template in the similar way than repeater :)

    post-2420-0-24685100-1410357136_thumb.jp

  8. Hello all,

    I am thinking how to make a "simple" button that could be edited by user.

    For example in a situation where we have an editable teaser and we want to add a internal link to some other page under it.

    The button/link would take two parameters:

    1.) Text that is displayed on a button (in different languages!)

    2.) Page to which button would link to.

    3.) Optional: instead of page object, one could also enter external address.

    System admin should also be able to add class name that would be added to rendered element.

    Field would then simply be used as: $page->button and it would render <a class='custom-class' href="$page->url">Text (in appropriate language)</a>

    I noticed it is sort of similar to this module, but with an option for user to select one of the pages (instead of writing down an ID).

    My first thoughts were to create Fieldtype/Inputtype module, but it seems sort of complicated (I don't know how to use neither FieldtypeTextLanguage nor FieldtypePage in module).

    So I wonder, how you guys are solving this problem?

    Thanks!

    Žiga

    PS.

    I am not sure I added this to the right section. If not, please feel free to move it where it's suppose to be.

  9. Hi all,

    First of all, thank you (Ryan) for building this awesome CMS and thank you (nice people on this forum) for keeping this welcoming/helpfull community.

    I recently found myself editing and changing .svg files to .inc files so I can include them with php, making them inline html elements, which allows me to use external css for manipulating them. Because doing this is sort of boring, and prune to mistakes (besides, it's much easier if one could just import svg file saved from illustrator), I started building a module which will take uploaded/submitted .svg file (using InputfieldFile) and:

    1.) add user-defined class to group that is wrapping all elements

    OR

    2.) wrap all elements into a group and add a user-defined class

    OR

    3.) just strip all tags (doctype, ...) except SVG tag.

    I have few problems and I am hoping you will be able to point me in the right direction:

    1.) Why is original (.svg) file not saved on server (module output is saved instead, although with different extension)?

    2.) How would I convince ProcessWire that it would render (only) those fields (that have this module enabled) as include("modified_file.inc");

    so I could just write f.example: <div.icon><?php $page_with_icon->icon; ?></div>

    3.) How come module's Boolean value in field's settings page is not saved, but text value (for class name) is?

    I am also attaching my .module file.

    Thank you for your help and please let me know, if I need to provide some additional information.

    Thanks! =)

    EDIT (30.7.2014):

    So, I will answer my own questions, if somebody will have same problems in future =)
    I solwed them like that:

    1.) File was not saved, because there was an error in module that was not being reported.

    2.) By using "$this->addHook("PageFile::includeSvg", $this, 'includeSvg');" where "includeSvg" is attached method. Method can now be used in templates with: $field->includeSvg(); 

    3.) It seems it needs to be called separately in function that is defining additional config options (in my case it's "addConfig") as: 

    $checked = $inputfield->makeInteractive == 1 ? "checked" : ""; $f->attr("checked", $checked);
     
    I am attaching modified (working) module. 

    interactiveSvg.module

×
×
  • Create New...