Jump to content

louisstephens

Members
  • Posts

    516
  • Joined

  • Last visited

Posts posted by louisstephens

  1. I just looked into Prepros and it looks awesome! I must say, I have been using gulp now for awhile and have never had an issue with browser-sync. However, I do find documentation/examples at time to be a bit overwhelming (especially when adding new plugins into your workflow).  I guess I got into it at the end of version 3, and the syntax changed in version 4 which really gave me a headache. 

  2. 5 minutes ago, a-ok said:

    This answer. Perfect.

    What about template and field names within PW? Thoughts?

    I have been curious about this as well. I am currently working on a project which unfortunately has grown to over 50+ fields (at the moment). I always see people writing about re-using fields as much as possible, but for the life of me I just get confused. I guess I just get hung up, ex: fields for  modal settings (header_color, width,  iframe_src)  and then having a different template that also has the same fields (but in a different context). I end up duplicating fields (which I know is terrible) and then going down a bad rabbit hole. 

  3. @wbmnfktr, that is what people are "claiming". If I had a surface/pencil combo, I would definitely use it. I have found though that just being able to use "cmd + tab" to quickly go to my not app without lifting off the keyboard is really useful for me. A lot of times I do just keep an empty txt doc open in text edit and "word vomit" into just for quick ideas/thoughts, and then just add them into notion later at the end of the day.

    • Like 2
  4. @Mithlesh, After looking at your template code, I do see the following (lines 18-29)

    <section class="map-image">
    <div class="container">
    	<div class="row">
    		<div class="col-md-12 col-sm-12 col-xs-12">
    			<div>
                    <img src="<?php echo adapt($page->header_image->last()); ?>">      
                </div>
     		</div>
     	</div>
     <!-- Tab Address -->
     </div>
    </section>

    All of this is coming in after the $form rendering on line 13. If you were to remove the section I posted above, the header image would not display.

    • Like 1
  5. In looking at the docs like you pointed out, I don't see anything related to 'story_fbid'. Couldn't you use the specific username to pull the post using:
     

    https://www.facebook.com/{page-name}/posts/{post-id}

    Sorry, I am sure you probably already tried that approach, but it is the only thing I currently see that might fit the bill.

  6. It really depends how your utilizing pages. For example:

    <?php
    header("Content-type: text/xml");
    
    $people = $pages->find('template=person'); // or whatever your template is
    
    $out = "<?xml version = \"1.0\"?>";
    $out .= "<contact-info>";
    
    foreach($people as $person) {
      $out .= "<name>" . person->title . "</name>"; // whatever field is storing the info
      $out .= "<company>" . person->company . "</company>"; // whatever field is storing the info
      $out .= "<phone>" . person->phone . "</phone>"; // whatever field is storing the info
    
    }
    
    
    $out .= "</contact-info>";
    echo $out;
    
    ?>

    The above would find all "people" and output them in contact info (well, everyone's info would be place inside the contact info tags). You could just move those tags inside the foreach loop if you needed each tag to have their own. Alternatively, you could use $pages->get() method to get a certain page (person. A little bit more information regarding your template structure could help us better give advice/pointers.

    • Like 1
  7. Not really sure where to post this, but I routinely receive a 502 Bad Gateway with the forums after I refresh. If I refresh after the error, the forum loads but the sidebar widget with "latest" posts is gone and just the user list is there. After a 2nd refresh, it loads normally. Has anyone else experienced this issue before or is the forum just being stubborn for me.

  8. On 6/19/2019 at 10:19 AM, elabx said:

    No ready-to-go module that I can find. I don't know the details but they seem to support basic authentication to the service just fine. So probably just install their library through composer (or manually) and do the API call on the POST request of your frontend form. 

    https://developer.mautic.org/?php#basic-authentication

    https://github.com/mautic/api-library

    To add on to elabx's response, I saw in Mautic's Developer Docs that there is a REST API with a methods for creating contacts etc etc: https://developer.mautic.org/#create-contact

     

  9. 2 minutes ago, buster808 said:

    Both sites are on a shared host and does have Wordpress websites on there.

     

    Since you do have wordpress installs on the server, it wouldnt hurt to log in and check/update any passwords, make sure wordpress is updated (could help with any vulnerabilites with bug fixes etc), make sure that all themes and plugins are up to date as well.

     

  10. From what I can tell, some might have gained access to your server/account . I have seen this before with wordpress sites. Has anything with your server changed lately? Also, I would check with your host to check if this is not just effecting you. Just in the short term, I would change your ftp credentials.

    • Like 4
  11. Well, I was really dumb here. All it took was me taking a break and coming back with some fresh eyes. After another failed attempt to get it working, I decided to bdump $rawTags and $tags and then it hit me. 

    $rawTags bdump: (which were the select values posted by the form): "1102,1103,1104,1105"

    $tags bdump (what BitPoet wrote me): array(1) 0 => "1102,1103,1104,1105"

    I was essentially passing an array with 1 item with all the ids. After using

    $tagsArray = explode(',', $rawTags);

    I get: array(4) 0=>"1102"  1=>"1103" 2=>"1104" 3=>"1105" and then it succesfully works with ->add(array($tagsArray)); 

    I appreciate everyone's help with this and patience. I can finally put this to bed.

    • Like 1
  12. I don't mean to keep this post going too long, but I am at a complete loss here and have no clue what else to do:

    $rawTags = $input->post->tags;
    tags = array_map(
    	function($tag) use($sanitizer) {
        	return $sanitizer->text($tag);
    	},
        is_array($rawTags) ? $rawTags : [$rawTags]
    );
    
    bdump($tags);
    bdump($rawTags);
    
    $p = $pages->get(1092);
    $p->of(false);
    
    foreach($tags as $tag) {
    	echo $tag;
    	$p->tags->add($tag); // add another page by id
    }
    $p->save();

    The above will only add one item even though I am foreach'ing through the array and the array (in testing) has 2 items in it. It also only works when 1 item is selected. If I select 2 items from the options field, it will not add either of the items. Is there a fundamental piece I am missing here, or am I going about this the completely wrong way? I am at my wits end with this?

     

    I did find 

    so I tried 

    $p = $pages->get(1092);
    $p->of(false);
    $p->dev_test->add(array($tags));
    bdump($tags);
    //add(array(1023,1026))
    //bdump($Test->id);
    $p->save();

    It works if just input 1102,1103 directly into the array like ->add(array(1102,1103)) , but not by passing my array to it.

  13. I would agree with Jonathan about relative urls. Also, I found if I have an existing live site that needs new updates, using github server hooks is a great thing. I simply push to github and I have a hook in github that will push it live to the server.

  14. Well, a little bit of an update. I just saw in my logs that I am getting an exception: "Page 1102 is not valid for tags ( Page 1102 does not have required parent 1015)"..

    I am wondering if my tag structure is messing up the Page field somehow as my select field on the front end is really only displaying:

    <select id="select_tags" name="select_tags" multiple="multiple">
    	<option value="">Select Your Tags</option>
    	<option value="1102">2018</option>
    	<option value="1104">2019</option>
    	<option value="1105">January</option>
    	<option value="1106">February</option>
    	<option value="1109">March</option>
    	<option value="1110">April</option>
    	<option value="1111">May</option>
    </select>

    I "omitted" the "Years", "Months" etc as I have them set to the template "parent-tag" while the actual "2019, January" are set to the template "tags".. I tried the "fix" from the following, but that doesnt seem to solve the issue either. It is odd to me that I can select via the admin and everything works fine.

    **Update**

    Using

    $rawTags = $input->post->tags;
    
    $p = $pages->get(1092);
    $p->of(false);
    bdump($rawTags);
    $p->dev_test->add($rawTags); //created a new page field without a "parent", just set the template
    

    This seems to add 1 page at a time now. However, it will not add multiple. I even tried to foreach through them to no avail.. Page fields obviously hate me today.

  15. Ah, they are indeed page names:

    <select id="select_tags" name="select_tags" multiple="multiple">
    	<?php $tags = $pages->find("template=tag"); ?>
        	<option value="">Select Your Tags</option>
        <?php foreach ($tags as $tag) : ?>
            <option value="<?= $tag->name; ?>"><?= $tag->title; ?></option>
    	<?php endforeach; ?>
    </select>

    And my Tag structure is set up like:

    Tags
    -Years
    --2018
    --2019
    -Months
    --January
    --February
    --Etc

    Sorry, I should have posted that earlier in my original post. So the url for the tag "2018" looks like "/tags/years/2018/" . I did change the output to be "ids" and then tried it out and it still isnt saving them. I really appreciate your help with this. If it is indeed recursive, I have no idea why " $p->tags->add($rawTags);" want work.

  16. Thanks again @BitPoet, I moved everything out into a new template so I could just test out the page reference field, and for some reason this is still blowing up in my face. I dont get the error like before, but it doesnt seem like anything is working. I simplified my php to:

    $rawTags = $input->post->tags;
    $tags = array_map(
    	function($tag) use($sanitizer) {
    		return $sanitizer->text($tag);
    	},
    	is_array($rawTags) ? $rawTags : [$rawTags]
    );
    
    $p = $pages->get(1092);
    $p->of(false);
    
    foreach($tags as $tag) {
    	$p->tags->add($tag);
    	bdump($tag);
    }
    $p->save();

    The bdump shows that $tag = "2018,2019" (which is what I selected from the options field on the frontend", but it does not seem like it is actually adding anything to the field in the backend. ?

  17. Thanks Bitpoet. I gave it a shot and I am getting: 

    #0 /MAMP/htdocs/development/wire/core/Selectors.php(460): ProcessWire\Selectors->create('hello', '', '')
    #1 /MAMP/htdocs/development/wire/core/Selectors.php(142): ProcessWire\Selectors->extractString('the-4th-of-july')
    #2 /MAMP/htdocs/development/wire/core/Selectors.php(128): ProcessWire\Selectors->setSelectorString('hello,the-4th-o...')
    #3 /MAMP/htdocs/development/wire/core/PagesLoader.php(221): ProcessWire\Selectors->init('hello,the-4th-o...')
    #4 /MAMP/htdocs/development/wire/core/Pages.php(246): ProcessWire\PagesLoader->find('hello,the-4th-o...', Array)
    #5 /MAMP/htdocs/development/wire/core/Wire.php(386): ProcessWire\Pages->___find('hello,the-4th-o...', Array)
    #6 /MAMP/htdocs/development/wire/core/WireHooks.php(733): ProcessWire\Wire->_callMethod('___find', Array)
    #7 /MAMP/htdocs/development/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'find', Array)
    #8 /MAMP/htdocs/development/wire/core/PagesLoader.php(430): ProcessWire\Wire->__call('find', Array)
    #9 /MAMP/htdocs/development/wire/core/Pages.php(390): ProcessWire\PagesLoader->get('hello,the-4th-o...', Array)
    #10 /MAMP/htdocs/development/wire/modules/Fieldtype/FieldtypePage.module(700): ProcessWire\Pages->get('hello,the-4th-o...')
    #11 /MAMP/htdocs/development/wire/modules/Fieldtype/FieldtypePage.module(563): ProcessWire\FieldtypePage->sanitizeValuePageArray(Object(ProcessWire\Page), Object(ProcessWire\Field), Array)
    #12 /MAMP/htdocs/development/wire/core/Page.php(1072): ProcessWire\FieldtypePage->sanitizeValue(Object(ProcessWire\Page), Object(ProcessWire\Field), Array)
    #13 /MAMP/htdocs/development/wire/core/Page.php(932): ProcessWire\Page->setFieldValue('tags', Array, true)
    #14 /MAMP/htdocs/development/wire/core/Page.php(1825): ProcessWire\Page->set('tags', Array)
    #15 /MAMP/htdocs/development/site/templates/ajax.php(64): ProcessWire\Page->__set('tags', Array)
    #16 /MAMP/htdocs/development/wire/core/TemplateFile.php(287): require('/Volumes/ArtDep...')
    #17 /MAMP/htdocs/development/wire/core/Wire.php(380): ProcessWire\TemplateFile->___render()
    #18 /MAMP/htdocs/development/wire/core/WireHooks.php(733): ProcessWire\Wire->_callMethod('___render', Array)
    #19 /MAMP/htdocs/development/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array)
    #20 /MAMP/htdocs/development/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array)
    #21 /MAMP/htdocs/development/wire/core/Wire.php(383): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent))
    #22 /MAMP/htdocs/development/wire/core/WireHooks.php(733): ProcessWire\Wire->_callMethod('___renderPage', Array)
    #23 /MAMP/htdocs/development/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array)
    #24 /MAMP/htdocs/development/wire/core/WireHooks.php(834): ProcessWire\Wire->__call('renderPage', Array)
    #25 /MAMP/htdocs/development/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Page), 'render', Array)
    #26 /MAMP/htdocs/development/wire/modules/Process/ProcessPageView.module(206): ProcessWire\Wire->__call('render', Array)
    #27 /MAMP/htdocs/development/wire/core/Wire.php(383): ProcessWire\ProcessPageView->___execute(true)
    #28 /MAMP/htdocs/development/wire/core/WireHooks.php(733): ProcessWire\Wire->_callMethod('___execute', Array)
    #29 /MAMP/htdocs/development/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageView), 'execute', Array)
    #30 /MAMP/htdocs/development/index.php(55): ProcessWire\Wire->__call('execute', Array)
    #31 {main}

    I guess I shouldnt be tryping to still pass $tags the same way I was with $p->tags = $tags? Sorry, I have never used array_map before so I wasnt sure of the desired output etc. I do appreciate the help

  18. Going through my long quest to get better with ajax and utilizing the api, I have hit yet another roadblock. I currently have a form with an image field (thanks to flydev for getting that sorted), "title" text input, and a select field set to multiple. In my ajax call, I added in:

    tags = $("#select-tags").val();
    form_data.append('tags', tags);
    
    $.ajax({
    	type: 'POST',
    	data: form_data,
    	contentType: false,
    	processData: false,
    	url: '/ajax/upload-preview/',
    	success: function(data) {
    		console.log("Woo");
    	},
    	error: function(xhr, ajaxOptions, thrownError) {
    		alert(xhr.responseText);
    	}
    });

    And in the ajax template: 

    $tags = $sanitizer->text($_POST['tags']);
    $image = $sanitizer->text($_POST['image']);
    $p = new Page();
    $p->template = "preview";
    $p->parent = $pages->get("/previews/");
    $p->name = $title;
    $p->title = $title;
    $p->tags = $tags;
    $p->save();

    If I select a "tag" from the select input and submit, it does indeed add it to the Page Reference field in the backend. However, this does not work with an array being passed to it of multiple options.

    47858297_ScreenShot2019-06-12at10_31_42AM.png.f3e6677b57cf8986202249a05a23b06b.png

    So it does appear that my ajax call is trying to submit multiple options, but I am really just unsure how to get these two added in. I saw in other forums posts of add($page) and even add(array()). Do I need to handle this js array differently or do  I need to foreach through the $tags to add it like:

      foreach($tags as $tag) {
            $p->tags->add($tag);
            $p->save();
        }

    I tried this approach, but apparently I am still missing something.

     

    Edit:

    I was doing some tweaking, and I know I can split the js array out like:

    for (i = 0, len = tags.length; i < len; i++) {
    	console.log(tags[i]);
    }

    However, I am not sure then how to handle the POST in php if I were to split it out.

×
×
  • Create New...