Jump to content

rooofl

Members
  • Posts

    56
  • Joined

  • Last visited

Recent Profile Visitors

3,421 profile views

rooofl's Achievements

Full Member

Full Member (4/6)

15

Reputation

3

Community Answers

  1. `$svgFont->filename` solved it! Thank you very much for your help @monollonom!
  2. After some tests, following your recommendations @monollonom, I face this error: Warning: XMLReader::open(): Unable to open source data in /home/…/www/site/templates/lib/EasySVG.php on line 161 It appears the path of `$svg->setFontSVG($fonturl.".svg");` is wrong, or at least not accessible by XMLReader. I checked: the file is readable. I also tested setFontSVG on a template file, it worked (can access to the SVG font and display the generated SVG). Finally, I tested with a static SVG font file to avoid the for loop, but it wasn’t able to open it neither. Here is my code in ready.php: <?php require './templates/lib/EasySVG.php'; wire()->addHookBefore("Pages::saveReady", function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); if($page->template->name !== "font") return; // or whatever if(!$page->webfont_archive && !$page->text) return; // file and text inputs $archivePath = $page->webfont_archive->path; $archiveUrl = $page->webfont_archive->url; $files = glob($archivePath . '*.{svg}', GLOB_BRACE); $len = count($files); for ($i = 0; $i < $len; $i++) { $fontpath = $files[$i]; $fontpath = substr($fontpath, strlen(wire()->config->urls->root)); $fontname = basename($fontpath, ".svg"); $fonturl = $archiveUrl.$fontname; echo $fonturl.".svg"; $svg = new EasySVG(); $svg->setFontSVG($fonturl.".svg"); $svg->setFontSize(100); $svg->setFontColor('#000000'); $svg->setLineHeight(1.2); $svg->setLetterSpacing(.1); $svg->setUseKerning(true); $svg->addText("demo text"); list($textWidth, $textHeight) = $svg->textDimensions("demo text"); $svg->addAttribute("width", $textWidth."px"); $svg->addAttribute("height", $textHeight."px"); // $page->svg_text = $svg->asXML(); // textarea input $page->svg_text = "test"; // textarea input $event->arguments(0, $page); } }); Any help welcome!
  3. Thank you very much for your inspiring, and detailed answer @monollonom I am going to make some tests very soon, also I didn’t know the existence of inputfield-runtime-only it solves a blurry area in my view of the process!
  4. Hi! We are Velvetyne Type Foundry, since 2010, we’ve designing and distributing free and open source typefaces. We are a non-profit organization. We are quite famous in the world of type design and open source design. We are currently working on a new website. We are focused on performances, and we want to show our fonts as SVG and not webfonts on our home page. Our website is currently using Processwire, and we want to stick to it because it’s amazing. I (author of this post) will take care of most of the development. We need a plugin that is able to generate an SVG path from a font file (present on the server), and a text. This script already does that pretty well and I think it can be a strong base for the font-to-SVG operation. We just want the admin page to be very user-friendly, taking care of the call to the font to SVG script and show its output. I wonder if anyone is able to do such a plugin an how much it can cost. Let me know if you can be interested.
  5. Thank you @BitPoet this makes totally sense, I should have thought about that. That solved my issue and I am super happy.
  6. Thank you for letting me know about wire('log'), it is much more handful that the way I found to debug. This is what my $image object looks like. I can’t find any documentation about this object and how to find the image url (for instance), or anything else to give to add(). InputfieldFormBuilderFile Object ( [data] => Array ( [label] => In use image [description] => Test desc [icon] => [notes] => [detail] => [head] => [required] => 1 [requiredIf] => [collapsed] => 0 [showIf] => [columnWidth] => [skipLabel] => [wrapClass] => [headerClass] => [contentClass] => [textFormat] => 4 [renderValueFlags] => 0 [prependMarkup] => [appendMarkup] => [formID] => 1 [entryID] => 0 [processor] => FormBuilderProcessor Object ( [data] => Array ( [id] => 1 [saveFlags] => 9 [skipSessionKey] => [formName] => new-inuse [submitText] => Submit [honeypot] => [turingTest] => Array ( ) [emailTo] => [emailFrom] => [emailFrom2] => [emailSubject] => Form Submission [responderTo] => [responderFrom] => [responderSubject] => Auto-Response [responderBody] => [successUrl] => [successMessage] => Thank you, your form has been submitted. [errorMessage] => One or more errors prevented submission of the form. Please correct and try again. [action2] => [action2_add] => Array ( ) [action2_remove] => Array ( ) [action2_rename] => Array ( ) [akismet] => [allowPreset] => [savePageParent] => 1006 [savePageTemplate] => 43 [savePageFields] => Array ( [name] => related_font [1] => title [114] => in_use_image ) [savePageStatus] => 0 [framework] => Basic [fbForm] => FormBuilderForm Object ( [forms:protected] => FormBuilderMain Object ( [formNames:protected] => Array ( [1] => new-inuse ) [database:protected] => WireDatabasePDO Object ( ) [filesPath:protected] => /site/assets/cache/form-builder/ [config:protected] => Config Object ( [data] => Array ( [dbName] => velvetyndev [internal] => 1 [urls] => Paths Object ( [data] => Array ( [wire] => wire/ [site] => site/ [modules] => wire/modules/ [siteModules] => site/modules/ [core] => wire/core/ [assets] => site/assets/ [cache] => site/assets/cache/ [logs] => site/assets/logs/ [files] => site/assets/files/ [tmp] => site/assets/tmp/ [templates] => site/templates/ [fieldTemplates] => site/templates/fields/ [adminTemplates] => wire/templates-admin/ [AdminThemeUikit] => wire/modules/AdminTheme/AdminThemeUikit/ [AdminThemeReno] => wire/modules/AdminTheme/AdminThemeReno/ [AdminThemeDefault] => wire/modules/AdminTheme/AdminThemeDefault/ [FileCompilerTags] => wire/modules/ [PageFrontEdit] => wire/modules/Page/PageFrontEdit/ [ProcessPageView] => wire/modules/Process/ [ProcessPageSort] => wire/modules/Process/ [ProcessPageSearch] => wire/modules/Process/ProcessPageSearch/ [ProcessPagesExportImport] => wire/modules/Process/ProcessPagesExportImport/ [ProcessRecentPages] => wire/modules/Process/ProcessRecentPages/ [ProcessHome] => wire/modules/Process/ [ProcessModule] => wire/modules/Process/ProcessModule/ [ProcessPageEdit] => wire/modules/Process/ProcessPageEdit/ [ProcessTemplate] => wire/modules/Process/ProcessTemplate/ [ProcessPageLister] => wire/modules/Process/ProcessPageLister/ [ProcessLogger] => wire/modules/Process/ProcessLogger/ [ProcessForgotPassword] => wire/modules/Process/ [ProcessPageAdd] => wire/modules/Process/ProcessPageAdd/
  7. Thank you for your answer and for pointing my mistakes! Here is an updated code with a new error. Somehow add() refuse the $image object: $forms->addHookBefore('FormBuilderProcessor::processInputDone', function($e) { $form = $e->arguments(0); if($form->name == 'new-inuse') { $font = $form->getChildByName('related_font'); $fontName = $font->attr('value')->name; $fontPage = wire('pages')->findOne("name=$fontName"); $image = $form->getChildByName('in_use_image'); $fontPage->of(false); $fontPage->in_use->add($image); $fontPage->save(); } }); Error: Exception: Item added to Pageimages is not an allowed type (in wire/core/WireArray.php line 286) How can I make sure $image is a valid image object? I tried to echo $image->url but nothing is happens.
  8. Hi! I am trying to create a hook that takes the value of a form file field, and add it to an image gallery of an existing page. $forms->addHookBefore('FormBuilderProcessor::processInputDone', function($e) { $form = $e->arguments(0); if($form->name == 'new-inuse') { // related_font is a page selector $font = $form->getChildByName('related_font'); // getting the page name $fontName = $font->attr('value')->name; // finds the page from its name $fontPage = wire('pages')->find("name=$fontName"); // in_use_image is a file upload field $image = $form->getChildByName('in_use_image'); // trying to add the image to the existing image gallery in_use field $fontPage->in_use->add('$image'); // error here $fontPage->save(); } }); This outputs the following error: `Call to a member function add() on null`. Any idea what’s wrong with my code?
  9. Great! $sanitizer->pageName("raphaël", true) does the trick indeed. Thank you!
  10. I need to find the sinitizer used to generate page names from page titles. I found $sanitizer->pageName() but it seems to ignore special characters: With $sanitizer-> pageName(), raphaël becomes raphal, however in the PW back-end the page title raphaël becomes raphael. Any idea what I should use instead?
  11. Thank you both, I didn’t understand the use of of(false).
  12. Saving the page doesn’t solve my problem…
  13. Hello, I am trying to add a page to Page Reference field. Here is what I do: $testpage = $pages->get(1252); // Page to edit $designersField = $testpage->designers; // Page field to fill $designerArray = []; $toadd = $pages->get(1200); // Page to add array_push($designerArray, $toadd); $designersField = PageArray($designerArray); // $testpage->save(); should I save? var_dump($designersField); When I var_dump() the page, I can see that my `designer` page has been aded. However in the admin page view, nothing is listed in the AsmSelect field. What do I miss?
  14. I can’t figure what is happening: I can echo the page I select using find("template=…") but when I pass it to render() nothing is listed. Everything works fine with the basic-page template however. $items = $pages->find("template=basic-page"); // working $items = $pages->find("template=ressource"); // not working with my custom template $rss->render($items);
  15. I can’t list my selected page, just like @adickman. I suspect it is related to the page or field permissions because 1. I can see other templates (basic-page for instance), 2. if I comment the viewable condition in the MarkupRSS module, I can see my feed correctly. I also tried to check the “Make field value accessible from API even if not viewable (see below)*” box on my template page but it does not work. What else can cause a page’s template to be inaccessible from the API?
×
×
  • Create New...