Loadposition does not seem to work when using ajax to retrieve articles

rawcoder
rawcoder used Ask the Experts™
on
To satisfy a clients needs, I had to create a custom component to retrieve the articles from the site and pass the article to ajax code to display the site.  I am now faced with a dilemma when I try to display articles that have {loadposition positionName}, where positionName represents the name of a module position.  Whenever ajax displays the page, it appears with the text {loadposition positionName} instead of the actual module position.  Is there a way I could invoke the step that substitutes the {loadpostion positionName} before I pass the article along to ajax?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
please show we the code and an example of url

Author

Commented:
Which part, ajax or component?  The component is literally being passed an id to an article and it is retrieving for ajax from there.  The real issue seems to be that in doing it this way, I am bypassing the process that performs the substitution of the loadposition.
leakim971Multitechnician
Top Expert 2014

Commented:
>The real issue seems to be that in doing it this way, I am bypassing the process that performs the substitution of the loadposition.

yes, the job is done on the server when you request the page the rigtht way, so I ask you the code you use to see how you ask it.
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Author

Commented:
select jm.id, jm.title, jm.link lnk, jmt.id menuid, ifnull(num_children,0) num_children,
case when instr(jm.link, '&id=') = 0 then '0' else substring(jm.link, instr(jm.link, '&id=') + 4) end content_id
from jos_menu jm inner join jos_menu_types jmt on (jm.menutype like jmt.menutype)
left join (
                select parent_id, count(id) num_children
                from jos_menu
                group by parent_id
            ) jms on (jm.id = jms.parent_id)
where substring(jm.link, instr(jm.link, '&id=') + 4) regexp '^-?[0-9]+$' and jmt.id = " . $id . " order by jm.title asc

Author

Commented:
I pass the result of this query back to ajax
leakim971Multitechnician
Top Expert 2014

Commented:
ok I just want to know you did not really load the page
you may have something like smarty playing with the content before sending it to the client side
you should request the page itself (with php or with js/jquery) and return the part you want

Author

Commented:
ok how do I do that?  I dont want the whole page, just the part that should display in the article, including the loadposition items.  And yes, I loaded the page from ajax and it technically works except for this issue.
Multitechnician
Top Expert 2014
Commented:
>I dont want the whole page
Ok so forget Javascript (without help of php), use something like that :

http://www.dreamincode.net/forums/topic/82274-php-curl-get-part-of-page/

Author

Commented:
The ajax part is unavoidable.  I have to perform some jquery animation with the data that I retrieve from joomla.  So, should I call the following code in my component "$page = file_get_contents("http://my.url.here");
preg_match_all("/<div>.+<\/div>/", $page, $matches);
print_r($matches);"?
leakim971Multitechnician
Top Expert 2014

Commented:
>So, should I call the following code in my component "$page = file_get_contents("http://my.url.here");
preg_match_all("/<div>.+<\/div>/", $page, $matches);
print_r($matches);"?

yes that is

Author

Commented:
Will this work if you have an outer div container like
<div>
<div>navigation area</div>
<div>body</div>
</div>
leakim971Multitechnician
Top Expert 2014

Commented:
I was assuming you know where you're going, if you really need help to find a good regex to get the right part/content of the page, it would be great to open a new question.

Personaly I use str_pos

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial