Avatar of rawcoder
rawcoder
 asked on

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

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?
PHPJoomlaAJAX

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon
leakim971

please show we the code and an example of url
rawcoder

ASKER
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.
leakim971

>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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
rawcoder

ASKER
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
rawcoder

ASKER
I pass the result of this query back to ajax
leakim971

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
rawcoder

ASKER
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.
ASKER CERTIFIED SOLUTION
leakim971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
rawcoder

ASKER
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);"?
leakim971

>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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
rawcoder

ASKER
Will this work if you have an outer div container like
<div>
<div>navigation area</div>
<div>body</div>
</div>
leakim971

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