Jump to content

presentation and ... asking for a help


xavier
 Share

Recommended Posts

Hello everybody,

I consider myself less than a newbie, I have entered in processwire world after a recommendation and instantly I liked it very much specially the way to to add information to the web and get easily pages from a dataset. Before, I had to add every page, every link manually.

I do not know almost anything of programming, I took an existing webpage, from an informatics course, and I am adapting it to my interests (you can visit it at http://www.bpod.cat). I know that it has something wrong because it is not as fast as I like but this is not the main problem now.

The problem is that I would like to filter the files by date. Every day has a new file and may sometimes we add files previous to the present day. I would like that the system could filter files by date and showed, automatically, only files from present day to the past.


The script I use is:

<script>
app.controller('FotosCtrl',function($scope,$http,pw){
	$scope.busca = function(){
		pw.busca('template=foto, title|comentari~='+$scope.termino).then(function(data){
		console.log("ENCONTRADOS",data);
		$scope.encontrados=data;
		$scope.termino='';
	});
}

$scope.buscaFotos= function(fotos){
	pw.busca(fotos).then(function(data){
		$scope.encontrados=data;
		console.log("todos",data)	
	});
}

$scope.buscaFotos('template=foto,sort=-any, sort=-mes, limit=1, sort=-ordre, ');
$scope.page=<?php echo $page->toJSON() ?>;
console.log("PAGINA", $scope.page);
});

</script>

 

And then, for instance, to select some files I use this sentence:

 

<a href ng-click="buscaFotos('template=foto,any=2017,mes=01,sort=ordre')">Gener</a>

But, I can't filter the files automatically by date (to show only present day and before).

 

I have searched in this forum some questions about date filtering and I do not know how to introduce the changes or have use it wrongly.

Addtionally, I have introduced some date fields, one without data (date) (to be always present day) and other with the proper day (datefixa) but I also do not know how to comparare each other to get a valid result.

I hope this question it is not out of range and someone could help me.

Have a nice day.

Xavier

Edited by kongondo
Mod Note: Please use code blocks (see the <> icon), thanks.
Link to comment
Share on other sites

Hi @xavier, welcome to the ProcessWire forums.

The code you have posted looks like AngularJS - I'm not sure this is the right place to get support for that.

20 hours ago, xavier said:

I do not know almost anything of programming

If you are just getting started I suggest you use straight PHP and HTML for your first ProcessWire project and leave AngularJS until you are more familiar with ProcessWire. That way it will be easier for people to help you here in the PW forums.

Link to comment
Share on other sites

On 1/22/2017 at 3:25 AM, xavier said:

$scope.page=<?php echo $page->toJSON() ?>;

One thing I notice is that this looks like an incorrect mix of the PW PHP $page variable and the JS toJSON() method.

We also don't have any info about what pw.busca() does. I know its a search, but it would be good to see some code.

I have used Angular and PW together a lot, so I might be able to help here, but I honestly don't know exactly what isn't working yet.

Link to comment
Share on other sites

First  of all, thank you four your replies.

11 hours ago, Robin S said:

I suggest you use straight PHP and HTML for your first ProcessWire project and leave AngularJS until you are more familiar with ProcessWire. That way it will be easier for people to help you here in the PW forums.


I do not discharge change the code if necessary. It is a matter of calculate the time necessary
to change in one way or in another (I can't).

3 hours ago, adrian said:

One thing I notice is that this looks like an incorrect mix of the PW PHP $page variable and the JS toJSON() method.

 

 
The web works ok, so I think that sentence it is also correct. May be it is not the best, but it works.

What it is done in the web? Files are included in the template 'foto' which is child of the template 'fotos'. 
So files are searched according to the month and year, addtionally the user can navigate up or down, 
by an order stablished in the field 'ordre'.

3 hours ago, adrian said:

I honestly don't know exactly what isn't working yet.


What it is wrong? I do not know how to add and scope, formula or what else in order to select, permanent and automatically 
files by date (using a date field or whatelse needed).


3 hours ago, adrian said:

We also don't have any info about what pw.busca() does. I know its a search, but it would be good to see some code.

You are right, it is a search. However I am not sure which code is used in that function.

The following code is present in the module hanna-code and in file named pwangular.php:

<?php
header("Content-type: application/json");

	$request = file_get_contents('php://input');
	$data = json_decode($request,true);
	$query = $data["query"];

	// $selector = wire("sanitizer")->text($selector);
	try {
		$paginas = wire('pages')->find($query)->toJSON();
	} catch (Exception $e) {
		echo ("Check that sent fields and that of the DB are the same kind INT, TEXT, DATE...")
;
	}
		
	echo $paginas; return;

In the code of the first message, the word 'busca' means 'search. 'ENCONTRADOS' means 'found'. 'todos' means 'all'. May be this helps.

 

 

Thank you very much for your attention.

Link to comment
Share on other sites

On 1/22/2017 at 3:25 AM, xavier said:

I do not know almost anything of programming, I took an existing webpage, from an informatics course, and I am adapting it to my interests

@xavier - if you really don't know anything about programming then I have to agree with @Robin S - an AngularJS based site is not the place to start - there is so much more to consider. You need to figure out if your PW selector is getting the pages you want, and then make sure they are being returned as JSON and correctly parsed and outputted via Angular. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...