Jump to content

ngrmm

Members
  • Posts

    421
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by ngrmm

  1. i'm trying to attach a .ics-file to a mail

    The Page send sends out the email but only download the ics-file. Email has no attachments.

    	// event ID
    	$eventID = $input->get('eventID','int');
    	$event = $pages->get($eventID);
    
    	// config
    	$testEmail = $event->event_mail_test_adress;
    	$fromEmail = $event->event_mail_from;
    	$fromName = $event->event_mail_from_name;
    	$emailSubject = $event->event_subject;
    	
    	// .ics
    	$filename = $event->name;
    	header('Content-Encoding: UTF-8');
    	header('Content-type: text/calendar; charset=utf-8');
    	header("Content-Disposition: attachment; filename={$filename}.ics");
    
    	// fetch start date 
    	$event_start_ts = $event->getUnformatted("date_start");
    
    	// build the .ics data
    	$ical_data  = 'BEGIN:VCALENDAR';
    	$ical_data .= "\r\n";
    	$ical_data .= 'VERSION:2.0';
    	$ical_data .= "\r\n";
    	$ical_data .= 'CALSCALE:GREGORIAN';
    	$ical_data .= "\r\n";
    	$ical_data .= 'METHOD:PUBLISH';
    	$ical_data .= "\r\n";
    	$ical_data .= 'BEGIN:VEVENT';
    	$ical_data .= "\r\n";
    	$ical_data .= 'SUMMARY:'.$event->title;
    	$ical_data .= "\r\n";
    	$ical_data .= 'UID:' . md5(uniqid(mt_rand(), true)) . '@'.$config->httpHost;
    	$ical_data .= "\r\n";
    	$ical_data .= 'CLASS:PUBLIC';
    	$ical_data .= "\r\n";
    	$ical_data .= 'STATUS:CONFIRMED';
    	$ical_data .= "\r\n";
    	$ical_data .= 'DTSTART:'.date('Ymd', $event_start_ts).'T'.date("His", $event_start_ts);
    	$ical_data .= "\r\n";
    	$ical_data .= 'DTSTAMP:'.date('Ymd').'T'.date('His');
    	$ical_data .= "\r\n";
    	$ical_data .= 'LOCATION:'.$event->venue;
    	$ical_data .= "\r\n";
    	$ical_data .= 'URL:'.$event->httpUrl;
    	$ical_data .= "\r\n";
    	$ical_data .= 'END:VEVENT';
    	$ical_data .= "\r\n";
    	$ical_data .= 'END:VCALENDAR';
    
    	// HTML BODY
    	ob_start();
    	include('./_inc/emailbody.inc');
    	$emailBody = ob_get_clean();
    
    	// send email
    	$m = new WireMail();
    	$m->to($testEmail);
    	$m->from($fromEmail, $fromName);
    	$m->subject($emailSubject);
    	$m->bodyHTML($emailBody);
    	$m->attachment($ical_data);
    	$m->send();

     

  2. I have a page with a table. Each table row has a page-reference field and a checkbox.
    The Page sends emails to all users (page-refrence->email-field) and change the value of the checkbox in a row to 1.

    It works with this:

    <?php
    
    	// event ID fron url query
    	$eventID = $input->get('eventID','int');
    
    	// get event-page
    	$event = $pages->get($eventID);
    
    	// config
    	$fromEmail = $event->event_mail_from;
    	$fromName = $event->event_mail_from_name;
    	$emailSubject = $event->event_subject;
    
    	// email html body
    	ob_start();
    	include('./_inc/emailbody.inc');
    	$emailBody = ob_get_clean();
    
    	// make event-page editable
    	$event->of(false); 
    
    	// loop through table and send out emails
    	foreach($event->event_clients_list as $event_table_row) {
    		
    		// get client page
    		$clientPage = $event_table_row->client_name;
          
          	// get client email
    		$clientEmail = $clientPage->email;
    		
    		// if client isn't invited yet (checkbox not checked)
    		if($event_table_row->client_invited == '') {
    
    			// send email
    			$m = new WireMail();
    			$m->to($clientEmail);
    			$m->from($fromEmail, $fromName);
    			$m->subject($emailSubject);
    			$m->bodyHTML($emailBody);
    			$m->send();
    
    			// mark client as invited
    			$event_table_row->client_invited = 1;
    			$event->save('event_clients_list');	
    		}
    	}
    ?>

    But i have to use a variable in my emailbody.inc which i'm able to get in the table-loop.
    So i do the including of the body inside my loop. But this doesn't work anymore. Page sends out the emails but is unable to change the value of the checkbox.
    I get no errors!
    I'm using ProTable

    <?php
    
    	// event ID fron url query
    	$eventID = $input->get('eventID','int');
    
    	// get event-page
    	$event = $pages->get($eventID);
    
    	// config
    	$fromEmail = $event->event_mail_from;
    	$fromName = $event->event_mail_from_name;
    	$emailSubject = $event->event_subject;
    
    	// loop through table and send out emails
    	foreach($event->event_clients_list as $event_table_row) {
    		
    		// get client page
    		$clientPage = $event_table_row->client_name;
          
          	// get client email
    		$clientEmail = $clientPage->email;
    
    		// email html body
    		ob_start();
    		include('./_inc/emailbody.inc');
    		$emailBody = ob_get_clean();
    
    		// make event-page editable
    		$event->of(false); 
      
    		// if client isn't invited yet (checkbox not checked)
    		if($event_table_row->client_invited == '') {
    
    			// send email
    			$m = new WireMail();
    			$m->to($clientEmail);
    			$m->from($fromEmail, $fromName);
    			$m->subject($emailSubject);
    			$m->bodyHTML($emailBody);
    			$m->send();
    
    			// mark client as invited
    			$event_table_row->client_invited = 1;
    			$event->save('event_clients_list');	
    		}
    	}
    ?>

     

  3. I have a page which sends out an email based on queries in the url

    <?php
    
    	// event ID
    	$eventID = $input->get('eventID','int');
    	$event = $pages->get($eventID);
    
    	// config
    	$adminEmail = "events@test.com";
    	$fromEmail = "noreply@test.com";
    	$fromName = "test";
    	$emailSubject = "Test Email";
    
    	// HTML BODY
    	$emailBody = ""; // HOW TO ??? …
    
    	// send mail
    	$m = new WireMail();
    	$m->to($adminEmail);
    	$m->from($fromEmail, $fromName);
    	$m->subject($emailSubject);
    	$m->bodyHTML($emailBody);
    	$m->send();
    ?>

    The email body is a bit complex: standard html/css tables and some php (pw variables).
    I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it?
     

  4. i'm using a pw-page to output a newsletter-email and send it via promailer.
    this page has a textarea-field (ckeditor).

    i searched a lot but was able to find out how to automatically add inline style to a-tags. like:
     

    <a href="#" style="color:red;"></a>

    adding a class via mystyles.js or config.js will not work because it's a newsletter-email. mail-apps would override class-styles. it has to be inline

  5. i want to output some of my pagefields as options in a html select tag
    i can do this this way:

    $search_options = $templates->get("catalog_item")->fields;

    but i'm not able to sort them:

    $search_options = $templates->get("catalog_item")->fields("sort=label");

    array_multisort() ksort() doesn't work either. is sort limited to pagearrays?

  6. 1 minute ago, dragan said:

    e.g. why don't you use a separate parent and template for tags?

    i'm trying to reduce redundancy and creating a structure which can be used later (relation-links)
    some existing should be also used as tags beside the new ones.

     

    1 minute ago, dragan said:

    Do you have any settings in your parent templates that say "only pages with template x are allowed as children"?

    yes

    1 minute ago, dragan said:

    "extra template" = additional template?

    yes

     

    1 minute ago, dragan said:

    I guess the system is confused because you allow two templates for selecting, and is not sure where to create new pages. afaik there's no additional settings where you could define that. You'd probably have to create a hook for that.

    ok, i though PW would use the first settings (parent/template) for creating the new pages, and additional setting and selector for additional options

    any tutorials/how-to for backend-hooks?

     

  7. i'm using a page-field with the inputfield-chosen-select-multiple as a tag-system
    – there are two different templates (template_A & template_B) which can be chosen
    – and both have different parents (parent_of_A's & parent_of_B's)
    – new pages (tags) generated from this field should be children of parent_of_A's and have template_A

    so i've chosen parent_of_A's as the parent and template_A as template. and selected template_B as extra template. this is must because that how the system know where to put the new pages.
    but this does not work when i try to add other templates as extra-templates or with the selector string method.
    error says: not the right template

    only using selector-string-method works for choosing, but no new pages can be generated

  8. 6 minutes ago, Autofahrn said:

    ok, somehow mixed up that this.attr, doesn't work...

    To access individual fields and don't want to use JSON (any reason for that), you may inject that into your DOM tree and access relative to the parent element. That way you:

    - combine discrete information into some markup
    - deal with proper escapement of special chars etc.
    - send that markup to client
    - client needs to parse markup to retrieve discrete information (and decode handling of special chars)

    Using the JSON version is much more straight forward, scalable and takes care of most aspects of proper data escapement.

    reason is my shitty javascript skills. i'll give it a try ?

  9. 4 hours ago, Autofahrn said:

    Wondering if its not just:

    
    $.get(this.attr('href'), function(data) { 

      

    don't think so.

    i have a follow up question. i get data as a whole. is there a way to get the content of specific fields. like data->divWithClassX?
    i want to update the content of two different divs on the page.

    do i have to that with the json-method?

  10. i did, 500 error again!

    send	@	jquery.js:2
    ajax	@	jquery.js:2
    w.(anonymous function)	@	jquery.js:2
    (anonymous)	@	main.js:43
    dispatch	@	jquery.js:2
    y.handle	@	jquery.js:2

    main.js:43

    $.get($("this").attr('href'), function(data) { 

     

  11. my ajax-reload leads into a 500 error (console)
    am i missing something?

    i just want to reload the random content of the the #data-div

    template-markup:

    if(!$config->ajax) {
    	
    	include("./inc/header.inc");
    	
    	echo "<a href='$page->url' class='button' >PRESS THE BUTTON</a>";
    	
    	echo "<section class='content' id='data'>";
    		// some images
    	echo "</section>";
    	
    	include("./inc/footer.inc");	 
    }  
    
    else {
    	echo "<a href='$page->url' class='button' >PRESS THE BUTTON</a>";
    	echo "<section class='content' id='data'>";
    		// some images
    	echo "</section>";
    } 

    and js:
     

    $(".button").click(function() {
    	
    	$("#date").html("<p>Loading...</p>");
    	
    	$.get($(this).attr('href'), function(data) { 
    		$("#data").html(data); 
    	}); 
    	
    	return false; 
    
    }); 

     

     

  12. 1 minute ago, adrian said:

    Probably, but honestly as a user I think I might go back from uBlock to ABP to get this feature ? I actually really hate these cookie banners - who of us out there actually bother to use them to decline setting cookies anyway?

    true, i dont like them either. but due to GDPR is a european law to have them. technically you still have them even if they are blocked.
    only problem are clients who do not understand this ?

    but maybe you add a note into the module, that it might get blocked by adblockers.

    • Like 2
×
×
  • Create New...