Jump to content

Eunico Cornelius

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Eunico Cornelius

  1. On 4/6/2018 at 5:24 PM, DaveP said:

    If I understand correctly, in your $selector, use body^=$q instead of body~=$q. (Note caret instead of tilde.)

    See https://processwire.com/api/selectors/#operators

     I understand this part, and I have tried to do it with body^=$q, However in a search, this will only apply for the first part of the word. For example, if I have a question "What is the best pet" this will only work if I search for "wh" and it will not show if I even search for "best". I have read the documentation and body*=$q fits more for search queries. Thank you for you help :) . @DaveP @LostKobrakai

  2. I am trying to filter my $pages with a find($selector method). 

    $matches = $pages->find($selector);

    and this is an example of what my selector looks like

    $selector = "include=all, title|body~=$q, limit=50";

    In this case, it only searches according to the matching exact words.

    For example:we search="art", the result="art times","these art",....

    Is there any way to search based on the alphabet?

    For example: we search="ab", the result="absolutely correct","abstract art",....

  3. Hi, I am trying to create a PHP page in my website that is hidden and produce a plain JSON format. However, when I implement json_encode on my string, the result is not only a plain JSON but also a <!DOCTYPE HTML>.... I have created a new page and a new template that has it's cache disabled, but it still doesn't work.

    this is what my code looks like 

    <?PHP
    $useMain=false;
    $data = "[{'title':'AAAAA','url':'https://google.com'}]";
    header('Content-Type: application/json');
    echo json_encode($data);
    ?>

    This is what I currently get

    "[{'title':'AAAAA','url':'https:\/\/google.com'}]"<!DOCTYPE html><html>....</html>

    This is what I am trying to achieve

    "[{'title':'AAAAA','url':'https:\/\/google.com'}]"

    What am I missing here? I am also using ProCache.(dont know if it has any influence since I created and disable cache in a new template)

  4. 58 minutes ago, flydev said:

    Hi,

    check the doc :

     

    Your link markup should be something like that :

    
    <a href="{$page->myfilesfield->first->url}" download>download</a>

     

    A tutorial :

     

    I've seen this tutorial. However, I am trying to download the file by only using href="" and not tweaking _init.php. Let's say for example the file I have uploaded to the page is called sample.pdf . what would be the href parameter to download the file from the page?  

     

    I tried this 

    foreach ($page->files as $file) { 
            
            echo "<a href='{$page->files->url}' download>download {$file->name}</a><br>"; 
            
        }

    but it gives me a 403 error.

    Sorry I am new to this kind of thing.

    Help anyone?

  5. 4 minutes ago, alxndre said:

    What exact code are you running so we'd have an idea where the $ is coming from? I just tested right now:

    
    echo $datetime->convertDateFormat("Y-M-D","strftime");
    
    // output
    %Y-%b-%a

     

    I'm sorry I forgot to mention that what I used as the first parameter is from the array 

    $formats = $datetime->getDateFormats();

    which when implemented, will look like this

    $dateformat = $datetime->convertDateFormat($formats[4], 'strftime');

    why is it not doable to get the format from the list?

  6. Hi, I am new to process wire and I've been trying to change the date time format in my webpage according to its language selection(example: English 'd/m/y' , Deutsch: 'd.m.y'). I know that using 

    $datetime->getDateFormats();

    we can achieve the type of formats in the shape of indexes. Also, by using 

    $user->language->id

    we can know which language we are using. How do I combine this two functions so that when I select English/Deutsch, the date will be adjusted accordingly?

    Is there a specific function that can do this or is there any provided index in the $user->language somewhere. Thanks in advance :).

×
×
  • Create New...