Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
basic question about index.php
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lin Ma  
View profile  
 More options Nov 10 2012, 10:25 am
From: Lin Ma <lin...@gmail.com>
Date: Sat, 10 Nov 2012 07:25:56 -0800 (PST)
Local: Sat, Nov 10 2012 10:25 am
Subject: basic question about index.php

Hello guys,

I am using 1.8.8. In index.php under main folder, there is a code snippet
like this,

if (elgg_is_logged_in()) {
    forward('activity');

}

I think this code snippet will forward current user to Url "activity". My
question is, I cannot find there is any php file called activity in the
source tree. Any ideas?

thanks in advance,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Nov 10 2012, 1:06 pm
From: Steve Clay <st...@elgg.org>
Date: Sat, 10 Nov 2012 13:06:01 -0500
Local: Sat, Nov 10 2012 1:06 pm
Subject: Re: [Elgg development] basic question about index.php
On 11/10/12 10:25 AM, Lin Ma wrote:

> I think this code snippet will forward current user to Url "activity". My question is, I
> cannot find there is any php file called activity in the source tree. Any ideas?

Most Elgg pages do not call PHP scripts directly. Most requests are handled by
/engine/handlers/page_handler.php, which passes on control to the page handling system
http://docs.elgg.org/wiki/Engine/Controllers/PageHandler

Steve
--
http://community.elgg.org/profile/steve_clay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 11 2012, 3:10 am
From: Lin Ma <lin...@gmail.com>
Date: Sun, 11 Nov 2012 00:10:42 -0800 (PST)
Local: Sun, Nov 11 2012 3:10 am
Subject: Re: [Elgg development] basic question about index.php

Hi Steve,

Thanks for your reply. I am new to Elgg and I feel I like its simple style
and extensible framework design and passion to write some plug-ins.

For my question, I searched the source tree, and there are multiple
start.php files. Then I tried to search "activity" (which is the Url mapped
to), but find no results.

Two more questions,

- appreciate if you could let me know what is the rule to find which
start.php takes effect in my specific scenario/question?
- could you help to point me where Url "activity" is mapped to an action?
Sorry for that and I did investigation, but never found out as I am new to
the code base.

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pjotr  
View profile  
 More options Nov 11 2012, 3:21 am
From: Pjotr <pjotr.savit...@gmail.com>
Date: Sun, 11 Nov 2012 00:21:36 -0800 (PST)
Local: Sun, Nov 11 2012 3:21 am
Subject: Re: [Elgg development] basic question about index.php

Activity is part of the Elgg Core, it is not a plugin. It is registered
within <ELGG-ROOT>/engine/lib/river.php line 643
It reads like this:
elgg_register_page_handler('activity', 'elgg_river_page_handler');

As that is part of an *_init function, you can make an educated guess that
it is loaded when engine starts.
This is the line taking care of that:
elgg_register_event_handler('init', 'system', 'elgg_river_init');

This is not an action, it is more of a page. Actions are different things
in Elgg, those are mostly about being places when some from sends
information to get something done. Se some of the start.php files within
the plugins for examples, you are looking for elgg_register_action calls.

Hope that helps.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 12 2012, 11:34 am
From: Lin Ma <lin...@gmail.com>
Date: Mon, 12 Nov 2012 08:34:17 -0800 (PST)
Local: Mon, Nov 12 2012 11:34 am
Subject: Re: [Elgg development] basic question about index.php

Hi Pjotr,

Thanks for the detailed reply. I have made some further study and have two
more questions,

1. In Elgg's document for function "elgg_register_page_handle" =>
http://docs.elgg.org/wiki/Elgg_register_page_handler, the first parameter
represents page type.
My first question is how many page types are defined in Elgg, and what is
the principle of defining page type (so that I can understand in the future
what is the best
practices to reuse or define new page type in the future);
2. I read through code of elgg_river_page_handler, I am totally lost about
what happens when input is 'activity' for function call forward('activity')
of index.php.
I think elgg_river_page_handler is called, and input parameter is $page.
And what is the value of $page when called from forward('activity') ofindex.php?

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ismayil Khayredinov  
View profile  
 More options Nov 12 2012, 12:06 pm
From: Ismayil Khayredinov <ismayil.khayredi...@gmail.com>
Date: Mon, 12 Nov 2012 18:06:24 +0100
Local: Mon, Nov 12 2012 12:06 pm
Subject: Re: [Elgg development] basic question about index.php

Let's say you have the following URL structure:
www.my-elgg-site.com/custom_handler/view/2560/my-very-long-blog-title

When you hit this URL, elgg will attempt to call a registered page handler
for 'custom_handler' (e.g. a handler function registered with
elgg_register_page_handler('custom_handler', 'my_custom_handler_function'))

Elgg will call your my_custom_handler_function($segments, $handler); where
$segments is an array of segments in your url following your $handler =
'custom_handler'.

In case of activity, $segments are probably empty.

You can have as many handlers defined as you want. Just keep in mind that
handlers must be unique, or they might be overridden, depending on the
plugin priorities.

Perhaps, it would be best for you to seek help in the Elgg community.

--
*Ismayil Khayredinov*
hypeJunction
web development and services

  ismayil.khayredi...@gmail.com
  +420 774 693 672
  ismayil.khayredinov

*"Hope is a state of mind, not of the world. Hope, in this deep and
powerful sense, is not the same as joy that things are going well, or
willingness to invest in enterprises that are obviously heading for
success, but rather an ability to work for something because it is good"* -
Vaclav Havel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pjotr  
View profile  
 More options Nov 12 2012, 2:37 pm
From: Pjotr <pjotr.savit...@gmail.com>
Date: Mon, 12 Nov 2012 11:37:55 -0800 (PST)
Local: Mon, Nov 12 2012 2:37 pm
Subject: Re: [Elgg development] basic question about index.php

Hmm .... the first parameter is the name of the handler to be used, it is
not about type (as it has been noted already). This is a string
representation that you will see within the URL. As mentioned it should be
unique. I guess that the best strategy would be to use the name of the
plugin (as every plugin has a unique name anyway due to being a directory),
this seems like a good way to go. It looks like Core plugins do tend to
follow that logic.

Call to function forward('activity') does one thing - issues a header
redirect to an address (it also does some magic). Simply put - it will see
that something provided is not a URL, so it takes BASE_URL and adds
'activity' to that and redirects your browser there, the result is
something like that: http://your.base.url/activity

The logic of the index is easy, if the user is a logged in one
(non-anonymous) then there is not point in showing the index page, it just
redirects the users to activity page/pages, the system understands that
this is mapped to a handler (as it was registered): the logic
http://your.base.url/<HANDLER>/

So the first element after BASE_URL is the handler. That handler is mapped
to some function.

The $page is an array of whatever comes after the <HANDLER> part of the
URL, the easy explanation would be to take the string and explode that
using slash; something like explode("/", "first/second/third"). In reality
it is a bit more complex than that.

So, the elgg_river_page_handler function does pretty-much something like
that:
Sets page owner to be currently logged in user. Call to elgg_extract takes
the values of key 0 of an array, if that is not there 'all' will be used as
the default. Does a bit more magic and checking, set_input pushes page_type
to be available to the script being included next. Loads "pages/river.php"
starting from the Elgg install path. Returns "true" telling that everything
is handled and that is it.

If you open the <ELGG_ROOT>/pages/river.php file. You will see options
being examined and page being constructed. Function elgg_list_river calls
in the listing you see on the page. The rest of those call in sidebars,
filters and other elements.

And last example might be now easy to understand: a URL like
<BASE_URL>/things/view/1

Let us make a guess that there is a function things_page_handler that is
registered to that page (the page it not a script, but just a string mapped
to some handler - mo handler, no page; 404 response code).

So, getting to the point: $page will be:

array(
    0 => 'view',
    1 => 1
);

You can see the logic how things are mapped.

Hope that helps understad how things work. My explanations are a bit
chaotic and I tend to skip some things and exhibit jumpy logic; but I did
mu best.

Pjotr


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Nov 12 2012, 5:22 pm
From: Steve Clay <st...@elgg.org>
Date: Mon, 12 Nov 2012 17:22:09 -0500
Local: Mon, Nov 12 2012 5:22 pm
Subject: Re: [Elgg development] basic question about index.php
On 11/12/12 11:34 AM, Lin Ma wrote:

> I thinkelgg_river_page_handler is called, and input parameter is $page. And what is the
> value of $page ...

$page receives an array of the URL segments after "/activity/". E.g.

URL => $page value
------------------
/activity => []
/activity/friends/steve_clay => ["friends", "steve_clay"]
/activity/owner/steve_clay => ["owner", "steve_clay"]

I highly recommend setting up xdebug remote debugging and stepping through the code. It's
a pain to set up the first time, but you'll get a much better sense of what is happening.

Steve
--
http://community.elgg.org/profile/steve_clay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 13 2012, 8:39 am
From: Lin Ma <lin...@gmail.com>
Date: Tue, 13 Nov 2012 05:39:37 -0800 (PST)
Local: Tues, Nov 13 2012 8:39 am
Subject: Re: [Elgg development] basic question about index.php

Thanks Ismayil, your reply is very helpful.

My question is when forward ('activity'') is called, I think function
elgg_river_page_handler (in lib/engine/river.php) is called, I am confused
about what it is doing internally in the function. More details about my
confusion, from UI perspective, I think the main dashboard should be
displayed for that user, but from the code in elgg_river_page_handler (in
lib/engine/river.php), I cannot see any code responsible for displaying
friends list, group information, etc. Appreciate if you could help to
clarify.

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 13 2012, 10:59 am
From: Lin Ma <lin...@gmail.com>
Date: Tue, 13 Nov 2012 07:59:15 -0800 (PST)
Local: Tues, Nov 13 2012 10:59 am
Subject: Re: [Elgg development] basic question about index.php

Thanks for taking so much time to reply my question, Pjotr! Your reply is
really excellent and in-depth. Actually not jumpy, well organized. :-)

I studied code and most confusions are gone, one confusion left, I think
function "elgg_list_river" needs to be called in order to display a
logged-in user main page. But I do not see it is invoked in function
elgg_river_page_handler (I thought elgg_list_river should be called from
elgg_river_page_handler, when forward('activity') triggers
elgg_river_page_handler). Any comments?

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 13 2012, 11:01 am
From: Lin Ma <lin...@gmail.com>
Date: Tue, 13 Nov 2012 08:01:06 -0800 (PST)
Local: Tues, Nov 13 2012 11:01 am
Subject: Re: [Elgg development] basic question about index.php

Thanks for your advice, Steve!

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pjotr  
View profile  
 More options Nov 14 2012, 3:13 am
From: Pjotr <pjotr.savit...@gmail.com>
Date: Wed, 14 Nov 2012 00:13:19 -0800 (PST)
Local: Wed, Nov 14 2012 3:13 am
Subject: Re: [Elgg development] basic question about index.php

This last confusion is easily solved, elgg_list_river does get called. Just
look at the line before the "return true;". It issues a require_once on
<ELGG_ROOT_PATH>/pages/river.php, this will look for that file and include
its contents to the current function (this is the simplest explanation of
the idea).

If you look in there, there is a call to elgg_list_river on line 42. It is
given the options determined by the code above. This means that
elgg_river_page_handler does indeed run the function. It does add some more
views, uses "content" layout and outputs the page.

Hope that clears things out,
Pjotr


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lin Ma  
View profile  
 More options Nov 14 2012, 3:56 am
From: Lin Ma <lin...@gmail.com>
Date: Wed, 14 Nov 2012 00:56:03 -0800 (PST)
Local: Wed, Nov 14 2012 3:56 am
Subject: Re: [Elgg development] basic question about index.php

Thanks for your reply Pjotr,

You answered my question. In the past, my mistake is, the code calls
"pages/river.php", I mistakenly think it calls "lib/river.php". :-)

BTW: a non-technical question, why it is calld river? What does river mean
in Elgg? How this name is selected?

regards,
Lin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »